[英]How to detect an app extension is enabled in containing app on iOS 8?
我正在 iOS 8 beta 上开发自定义键盘,我想告诉用户如果我的自定义键盘未启用,如何在包含应用程序中启用它,有什么方法可以检测应用程序扩展是否已启用?
first of all let's set some constants to make it easy to understand each other:首先让我们设置一些常量,以便于相互理解:
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. Apple 还发布了一个更安静的 API,称为 App Groups API。这个 API 允许开发人员将 n 个扩展分组在 1 个捆绑标识符下,并在应用程序和其中包含的扩展程序之间创建通信线路。
you can share data between the extensions and the containing app using NUserDefaults, but with this new method:您可以使用 NUserDefaults 在扩展程序和包含的应用程序之间共享数据,但使用这种新方法:
[[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:使用应用组的 url 方案来测试你想要的:
https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSExtensionContext_Class/#//apple_ref/occ/instm/NSExtensionContext/openURL:completionHandler : 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
Good luck!!!祝你好运!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.