1

basically, i want to know if a device has icloud account signed-in, if yes, i'll store to icloud, if no, i'll store to my server. i am using objective-c on xcode6. i am currently using key-value store feature of icloud and everything works fine by now, but my problem is, how can i know if my device has icloud account signed-in? i am using these codes but it doesn't help because both codes return NO

- (BOOL)isCloudSetup
{
    id token = [[NSFileManager defaultManager] ubiquityIdentityToken];
    return token != nil;
}

- (void)refreshiCloudRoot:(void (^)(BOOL available))completion
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        _iCloudRoot = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
        if (_iCloudRoot != nil) {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSLog(@"iCloud available at: %@",_iCloudRoot);
                completion(YES);
            });
        } else {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSLog(@"iCloud not available");
                completion(NO);
            });
        }
    });
}

thanks in advance for those who can help.

Romz
  • 71
  • 5
  • possible duplicate of [How to programmingly detect if the iCloud is enabled on user's device when only use NSUbiquitousKeyValueStore?](http://stackoverflow.com/questions/11006610/how-to-programmingly-detect-if-the-icloud-is-enabled-on-users-device-when-only) – Kevin Nov 26 '14 at 03:44

0 Answers0