Search code examples
objective-ciosicloudkey-value-store

iCloud KeyValue store not recognized on first launch


My app uses iCloud (key-value store) to sync an unique id between multiple devices. This works accept at the point were it really has to work, at the first launch of the app. It looks like the device isn't yet familiar with the values from iCloud at first launch, only after the app is installed and has been running for a while.

I check for the iCloud value in the viewDidLoad function on main view of the app.

So, my questions:

  • Is this the expected behavior?
  • If yes, is there another solution?
  • Could it be the case this is only a problem when running from Xcode, not the shipping version? If so, how to test?

Thanks!

Jasper


Solution

  • When you first run an iCloud enabled App it has to pull all the data from Apple servers. The time it takes to do so depends on many things like what kind of network you're currently on (Edge, 3G, GPRS, WLAN). It also depends on how much traffic the iCloud server currently has to handle so the request to the iCloud server may take a few more seconds, no matter what type of network connectivity you have.

    To sum it up: Yes, it sounds absolutely normal.

    If running your App depends on those settings consider implementing a "Wait" or "Loading" view that stays on the screen as long as it takes for the App to perform a initial synch and load all needed data from the cloud. To not block the UI forever also implement a timeout for this view (if iCloud data not loaded within X seconds, dismiss the view and notify user).