Retrieve current iCloud account information in Xcode

How to get the current active iCloud username on an iOS device to show it in my application?

Code from the comment below OP

NSURL ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];

if (ubiq) 
{ 
    NSLog(@"iCloud access at %@", ubiq.user); // TODO: Load document... 
} 
else 
{ 
    UIAlertView alert=[[UIAlertView alloc]initWithTitle:@"No iCloud access" message:@"Please set your iCloud account in Setting-iCloud" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; // [alert show]; NSLog(@"No iCloud access"); 
}

If you know how to display your iCloud username, please tell me. I was already looking for this, but I could not find the answer to my question.

+4
source share
1 answer

You cannot do this. ICloud account details are not available to third-party applications. All you can find out is iCloud available for your application. The username is not accessible through any public API. The ubiquity container URL does not encode the iCloud username as well NSFileManager ubiquityIdentityToken.

+10

All Articles