ios8扩展和容器应用程序如何共享数据 [英] ios8 extension and container app how to share data

查看:203
本文介绍了ios8扩展和容器应用程序如何共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在iOS 8扩展程序和容器应用程序之间共享数据。
我从开发门户网站和Xcode设置了这个组,我的权利看起来像:

I'm having trouble to share data between iOS 8 extension and container app. I set up the group from develop portal and Xcode, and my entitlements plist both look like:

<dict>
    <key>com.apple.security.application-groups</key>
    <array>
        <string>my group id</string>
    </array>
</dict>

Apple文档中建议的解决方案使用 [[NSUserDefaults standardUserDefaults]

The suggested solution in apple document to use [[NSUserDefaults standardUserDefaults]

对我不起作用。

我已经尝试过@的解决方案来自这篇文章的圣诞老人在带有应用程序组的应用程序之间传递和保存数据使用

I've tried the solution by @Santa Claus from this post Communicating and persisting data between apps with App Groups to use

[[NSUserDefaults alloc] initWithSuiteName:@"<group identifier>"];

圣诞老人的解决方案适用于模拟器但不适用于我的iPhone 4s,任何有关如何使其工作的想法在真实设备上?或者我错过了什么?

Santa Claus's solution worked on simulator but not on my iPhone 4s, any ideas on how to make it work on real device? Or am I missing anything?

一些更新:

[[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group id"];

函数返回url,来自容器app和扩展名的两个url看起来都一样, path / private / var / mobile / Containers / Shared / AppGroup / 3DFB9750-A9F3-4C37-BC3C-0D5BF746B 233
我在容器应用程序中的该文件夹中创建了一个json文件,但是当我在设备上运行时,扩展程序无法在文件夹中找到任何文件。但是在模拟器中它找到了它并且一切正常。

function returns url, and both urls from container app and extension look the same, as "path /private/var/mobile/Containers/Shared/AppGroup/3DFB9750-A9F3-4C37-BC3C-0D5BF746B‌​233". I created a json file inside that folder from container app but extension can't find any file in the folder when I run on device. But in simulator it finds it well and everything works.

推荐答案

我的解决方案是编辑自定义键盘的Info.plist:

My solution is edit the Info.plist of my custom keyboard:

NSExtension - > NSExtensionAttributes - > RequestsOpenAccess

NSExtension -> NSExtensionAttributes -> RequestsOpenAccess

设为是。

然后删除你的键盘设备并重新添加。在键盘添加页面中,您将找到名为允许完全访问的设置,启用它,键盘将访问共享数据。

Then delete the keyboard in your device and re-add it. In your keyboard add page you will find a setting named "Allow Full Access", enable it and the keyboard will access the shared data.

这篇关于ios8扩展和容器应用程序如何共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆