Can you share data on CloudKit between different apps

不羁岁月 提交于 2019-11-30 16:54:24

问题


I have a free and paid version of my app in the app store. I'm updating the app to share some public data using CloudKit. I'd like both the free and paid apps to share the same data.

Firstly is it possible for two apps to share the same data with CloudKit?

If so, how can I get this to work? I've tried enabling CloudKit in the capabilities of both targets and selecting the same container in both apps. The main app which has 'Use default container' selected works fine, but the other app, on which I've selected 'Specify custom containers' and selected the custom container from the first target, gets an error back when I try to download anything.


回答1:


Yes, multiple apps can use the same CloudKit data. When you get your CKContainer, I assume you are using something like the following for both apps?

let container = CKContainer.defaultContainer()

This would work for the main app (the one with the bundle identifier that matches the cloudkit identifier). The other app(s) will need to initialize the container like so:

let container = CKContainer(identifier: "iCloud.com.example.appname")


来源:https://stackoverflow.com/questions/33478860/can-you-share-data-on-cloudkit-between-different-apps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!