ios - 在 Xcode 中检索当前 iCloud 帐户信息

标签 ios xcode icloud

如何在 iOS 设备中获取当前事件的 iCloud 帐户用户名以在我的应用程序中显示它?

代码来自 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"); 
}

如果您知道如何显示 iCloud 帐户用户名,请告诉我。我已经搜索过这个,但找不到适合我的案例的任何答案。

最佳答案

你做不到。 iCloud 帐户的详细信息不适用于第三方应用程序。您所能了解的只是 iCloud 是否可用于您的应用程序。用户名无法通过任何公共(public) API 获得。无处不在的容器 URL 不会对 iCloud 用户名进行编码,NSFileManagerubiquityIdentityToken 也不会。

关于ios - 在 Xcode 中检索当前 iCloud 帐户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21274515/

相关文章:

ios - Mapbox 中的离线用户位置

ios - iPhone - 当旋转动画 > 90 度时 UIImageView 移动

ios - 如何使用 Swift 5 从 iOS13 中的后台应用程序获取事件应用程序的名称?

ios - 在 CKFetchRecordChangesOperation 上进行大量更改是否正常?

ios - 从 iOS 应用分享照片

ios - 从自定义相册中删除图像

xcode 多合一布局 : keyboard shortcut to switch between project and debug page?

xcode - Xcode 4 中的乐器

iphone - 禁用 iCloud 同步

ios - 检测文件是否在 iCloud Drive Trash 中