Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - How to know if iCloud photo transfer ability is enabled

The new iCloud service has many possible configurations. How may I know if the device of my user is configured to send taken pictures to an iCloud server instead of storing them just on the device ?

like image 518
Oliver Avatar asked Nov 05 '11 14:11

Oliver


People also ask

How do I know if my photos are transferring to iCloud?

iCloud Photo Library is not enabled – Use your iPhone or iPad to navigate to Settings > [Your Name] > iCloud > Photos and make sure the slider next to iCloud Photos is green. If it is, iCloud Photos is enabled. If it's not, just tap it to change color and turn it on.

How do I know if iCloud is enabled on my iPhone?

On your iPhone, iPad, or iPod touchGo to Settings > your name. Tap iCloud. Tap to choose which apps you want to use iCloud.

How do I enable iCloud photo sharing?

Once you've installed iCloud For Windows, open it and sign in with your Apple ID. Use the same Apple ID that you use on your iPhone. Click the New Shared Album button at the top of the screen. Add the iCloud email addresses for the people you want to invite.


2 Answers

If you want to know if iCloud is activated you could simply call:

 NSFileManager *fileManager = [NSFileManager defaultManager];   
 NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];   
 if (cloudURL != nil) {   
    // iCloud is available
 }

This can give you a hint if iCloud is available at all. If you want to use iCloud to store pictures you can build your own stuff. I'm not really sure what you are planning to do.

like image 71
benjamin.ludwig Avatar answered Nov 10 '22 00:11

benjamin.ludwig


As long as you give a valid ubiquity container identifier below method should return YES:

static NSString *UbiquityContainerIdentifier = @"ABCDEFGHI0.com.acme.MyApp";

- (BOOL) iCloudIsAvailable
{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *ubiquityURL = [fileManager URLForUbiquityContainerIdentifier:UbiquityContainerIdentifier];
    return (ubiquityURL) ? YES : NO;
}

However, I've found that calling URLForUbiquityContainerIdentifier: might take time (several seconds) the very first time within a session. So, just make sure you call this in the background to not block the UI temporarily:

dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(backgroundQueue,^{
    BOOL isAvailable = [self iCloudIsAvailable]
    /* change to the main queue if you want to do something with the UI. For example: */
    dispatch_async(dispatch_get_main_queue(),^{
        if (!isAvailable){
            /* inform the user */
            UIAlertView *alert = [[UIAlertView alloc] init...]
            [alert show];
            [alert release];
        }
    });
});
like image 21
Shankar Aware Avatar answered Nov 09 '22 23:11

Shankar Aware