iCloud NSUbiquitousKeyValueStore initial sync/access delay - how to handle?

前端 未结 3 667
北恋
北恋 2020-12-29 07:15

I\'m using NSUbiquitousKeyValueStore to store some app settings. My logic is: when I save data locally, I save it to NSUbiquitousKeyValueStore also as a backup. When I need

相关标签:
3条回答
  • 2020-12-29 07:33

    Because obviously your app shouldn't hang while waiting for a slow netork. It's all in the iCloud Design Guide.

    Register for NSUbiquitousKeyValueStoreDidChangeExternallyNotification, call -synchronize, and hopefully a notification should eventually arrive.

    If the data is already up-to-date, I don't think you get a notification, and I don't think there's an wasy way to know how old the data is.

    0 讨论(0)
  • 2020-12-29 07:39

    I am setting one dummy key to NSUbiquitousKeyValueStore and calling synchronize on app launch. The result is not 100% solution but somewhat better. You can try this.

    0 讨论(0)
  • 2020-12-29 07:53

    Conclusion

    Temporary solution is: - call synchronize before get data from key-value store - to be sure it would work "turn off iCloud->Documents&Data - turn off and again on network - turn on Documents&Data", but also you should wait several minutes before iCloud downloads all needed data

    Note: when app is installed and already worked (saved/loaded) with key-value store updates of iCloud data are pretty fast (7-15 sec), but when you reinstall the app it seems that icloud needs several minutes to actualize key-value store.

    I'd be glad to hear your thoughts, because icloud looks like almost unusable feature. But I don't want to set up my own server to merely get the same functionality.

    0 讨论(0)
提交回复
热议问题