使用相同的普遍容器在多个应用上存储iCloud密钥值

时间:2014-02-05 10:47:53

标签: ios macos icloud-api nsubiquitouskeyvaluestore

我知道此类问题之前已经以类似的方式提出,但没有找到令人满意的答案。有人可以对此有所了解。在我开始提问之前,我想补充说,App ID已启用iCloud,之后会创建/下载/安装临时配置文件。

我在这里跟踪了Apple文档https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/iCloudFundametals.html

Configuring a Common Ubiquity Container for Multiple Apps
In the Xcode target editor’s Summary tab, you can request access to as many ubiquity containers as you need for your app. For example, say you provide a free and paid version of your app. You’d want users, who upgrade, to retain access to their iCloud documents. Or, perhaps you provide two apps that interoperate and need access to each other’s files. In both of these examples, you obtain the needed access by specifying a common ubiquity container and then requesting access to it from each app.

To configure a common ubiquity container
Pick one of your iCloud-enabled apps to serve as the primary app for the common ubiquity container.

The app you pick can be the current one you are developing, or another app of yours submitted for distribution in the App Store and whose entitlements use the same team ID.

In the first row of the Xcode target editor’s iCloud Containers list, enter the bundle identifier of your primary iCloud-enabled app.

If you then look in the .entitlements property list file, you’ll see that Xcode has automatically qualified the identifier string by prefixing it with your team ID.

To retrieve a URL for a ubiquity container, you must pass the fully qualified string to the NSFileManager method URLForUbiquityContainerIdentifier:. That is, you must pass the complete container identifier string, which includes your team ID, that you see in the .entitlements property list file. You can pass nil to this method to retrieve the URL for the first container in the list.

For more information about how to configure entitlements, see “Configuring Store Technologies in Xcode and iTunes Connect” in App Distribution Guide

我有一个MAC应用程序和一个iOS应用程序。在MAC应用程序的功能部分中,iCloud已打开。 Ubiquity容器包含我的MAC应用程序的包标识符。我检查了.entitlement文件,iCloud密钥值存储是TeamIdentifier.bundleidentifier。一切正常。值存储在iCloud中,我可以毫无问题地获取它们。

现在在我的iOS应用上。在功能部分,我已经打开iCloud并将ubiquity容器字符串设置为我的MAC应用程序的包标识符。选中的.entitlement文件和iCloud密钥值存储字符串设置为TeamIdentifier.bundleidentifier。当我从iCloud获取时,我的iOS应用程序的值变为零。我已经在模拟器和iPhone 5上测试了它,但没有运气。

非常感谢任何帮助。

0 个答案:

没有答案