Are data in an iCloud NSUbiquitousKeyValueStore directly available at app launch on another device?

Hello,

I'm planning to had an onboarding to one of my apps. I am thinking about a way for a user to not see the onboarding again if he installs the app on another device. So for example, the user completes the onboarding on its iPhone, then downloads the app on its iPad and launch it, he doesn't see the onboarding a second time.

I thought about using iCloud NSUbiquitousKeyValueStored to store the onboarding completion state.

But I'm not sure when the data is synced to the other device logged into the same Apple account:

  1. Immediately even if the app is not installed on the other device (independent from the app, only iCloud thing)?
  2. At the same time as the app install on the other device?
  3. After the app is first launched on the other device?

Of course synchronisation will depend on the Internet connection, speed, etc. so the app should handle the case where the data is not here but what would be the best case scenario?

Thank you, Axel

Answered by DTS Engineer in 852688022

Typically, a synchronization activity happens shortly after a CloudKit app is launched. (NSUbiquitousKeyValueStore is based on CloudKit, btw.)

If you observe didChangeExternallyNotification, you can expect to get a notification about the remote changes shortly after your app is launched.

The following sample app demonstrates how NSUbiquitousKeyValueStore works, which you can probably use to verify the behavior:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Typically, a synchronization activity happens shortly after a CloudKit app is launched. (NSUbiquitousKeyValueStore is based on CloudKit, btw.)

If you observe didChangeExternallyNotification, you can expect to get a notification about the remote changes shortly after your app is launched.

The following sample app demonstrates how NSUbiquitousKeyValueStore works, which you can probably use to verify the behavior:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Are data in an iCloud NSUbiquitousKeyValueStore directly available at app launch on another device?
 
 
Q