问题
has anybody managed to get iCloud working on tvOS so far?
I am using key-value-storage and it successfully saves everything in iCloud. However, it does not synchronize the data between the iOS-App and the tvOS-App. I am using the same bundle-identifier for both apps.
Has anyone experienced the same issue?
回答1:
So, it appears that Apple may have an issue here on the tvOS side, because if I follow Apple's instructions on Configuring Common Key-Value Storage for Multiple Apps I can share between and iOS App and a macOS App, but not the tvOS app using exactly the same setup.
Below are my results:
Apple's Instuctions that I used 1st:
So, CloudKit is all about the default Container rather than the App bundle ID directly. So, I setup my Primary iOS app with default container that will become the key-value share container.
Here is my Primary Entitlements file: I then stored two NSUbiquitousKeyValueStore pairs in the default store and retrieved the values:
NSUbiquitousKeyValueStore.defaultStore().dictionaryRepresentation
So, in my macOS app I enable CloudKit as well, and remove the default container and set it to the Primary iOS apps container. Then in the Entitlements file I manually setup the com.apple.developer.ubiquity-kvstore-identifier
to include the Primary App's bundle ID:
Uncheck default container and toggle Primaries:
Here is my Secondary macOS Entitlements file:
Then I run the macOS app and presto, I have the key-value pairs from the primaries default key-value store and retrieved the values easy-peasy:
NSUbiquitousKeyValueStore.defaultStore().dictionaryRepresentation
If I then make the SAME EXACT MODIFICATIONS to my tvOS app, the defaultStore() show as empty and I cannot get it to share with the iOS and macOS app.
Here is my Secondary tsOS Entitlements file:
And no presto, no values:
来源:https://stackoverflow.com/questions/36716740/icloud-synchronization-on-tvos