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 ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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:
https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSExtensionContext_Class/#//apple_ref/occ/instm/NSExtensionContext/openURL:completionHandler:
- (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!!!