问题
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