I am developing a custom keyboard on iOS 8 beta, and I want to tell the user that how to enabled it in containing app if my custom keyboard is not enabled, is there any way to detect an app extension is enabled ?
Asked
Active
Viewed 2,193 times
9
-
Similar (more recent) question: http://stackoverflow.com/questions/25675628/how-to-detect-whether-custom-keyboard-is-activated-from-the-keyboards-container/25714326#25714326 – dandoen Sep 09 '14 at 08:17
1 Answers
-2
first of all let's set some constants to make it easy to understand each other:
- containing app = the app that installs the extension and holds the extension binary and target
- host app = the app that the extension is running inside (other party)
- extension = any of iOS8's new components/modules that we can now build into system-wide use: custom keyboards, today widgets, photo editing effects, and more..
Apple also released a more quiet API called App Groups API This API allows a developer to group n extensions under 1 bundle identifier, and creates a communication wire between the app and the extensions contained in it.
you can share data between the extensions and the containing app using NUserDefaults, but with this new method:
[[NSUserDefaults alloc] initWithSuiteName:@"<app group identifier>"];
read/write... and sync:
[myDefaultsObj synchronize];
and now to the bottom line:
use the app group's url schemes to test what you want:
- (void)openURL:(NSURL *)URL completionHandler:(void (^)(BOOL success))completionHandler
- URL - The URL to open.
- completionHandler - A block that is called when the URL has opened.
- this parameter - success - is a Boolean value that indicates whether the open was successful.
Good luck!!!

pkamb
- 33,281
- 23
- 160
- 191

nurnachman
- 4,468
- 2
- 37
- 40
-
2The method "(void)openURL:(NSURL *)URL completionHandler:(void (^)(BOOL success))completionHandler" is only available in app extension, I want to detect APP EXTENSION is enabled or not at CONTAINING APP. – moligaloo Jul 03 '14 at 06:57
-
`[NSExtensionContext openURL:completionHandler:]` will always fail for extensions other than Today extensions – user102008 Aug 29 '14 at 21:52