Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine availability of iCloud Key Value Store

I am working on OSX 10.8 application that uses iCloud Key Value store. It does not use Document storage.

I would like to determine if iCloud Key Value store is available for a user.

I was trying to use cloud like:

+ (BOOL)isCloudAvailable {
       id currentCloudToken = [NSFileManager defaultManager] ubiquityIdentityToken];
       return (currentCloudToken) ? YES : NO;
}

However, the call to ubiquityIdentityToken always returns nil, even when a user is logged into iCloud.

If I configure a Ubiquity Container as well as the key-value store then that call does work.

However, I've just had my app rejected by Apple review for indicating I need "Document & Data storage" without having any requirement in the app for it. I was simply using it to determine if iCloud was available.

Is there anyway to determine if iCloud key-value store alone is available to a user?

like image 689
Damien Avatar asked Jun 12 '13 05:06

Damien


1 Answers

The iCloud Fundamentals guide has a table that compares Document Storage to the Key-Value Store(Table 1-1). In contrary to Mobile Documents, the Key Value Store should be considered Always effectivly available.

The [NSUbiquitousKeyValueStore defaultStore] also isn't nil when iCloud is not enabled, and it even stores key/value pairs - It just doesn't upload them to the iCloud server. From the NSUbiquitousKeyValueStore's point of view there is little difference between offline and logged-out.

You also have to keep in mind that already stored values are pushed to the server as soon as the device attaches to the account. It might be necessary to handle conflicts (if the default last-one-wins strategy doesn't work for your use case).

like image 150
Thomas Zoechling Avatar answered Sep 29 '22 16:09

Thomas Zoechling