iphoneiosipadios6icloud

How to detect if the user has iCloud enabled for my app?


I have developed an iCloud enabled iPhone App. The issue I am facing is that even if the user turns off iCloud backup for my App then also it takes back up on iCloud and reflect changes on my other devices, so I want to know that how can I get that my App is iCloud enabled or not.

It's specifically for App not for Device, if device is iCloud enabled, but my App is turned off then it should not take any backups.


Solution

  • Please use this to check the status of your iCloud whether it is enabled or not .

    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:nil]; 
    NSLog(@"%@", [iCloudURL absoluteString]); 
    
    if(iCloudURL){ 
    NSUbiquitousKeyValueStore *iCloudStore = [NSUbiquitousKeyValueStore defaultStore]; 
    [iCloudStore setString:@"Success" forKey:@"iCloudStatus"]; 
    [iCloudStore synchronize]; // For Synchronizing with iCloud Server 
    NSLog(@"iCloud status : %@", [iCloudStore stringForKey:@"iCloudStatus"]); 
    }
    

    This will tell you whether it is ON/OFF :)