【问题标题】:Retrieve current iCloud account information in Xcode在 Xcode 中检索当前 iCloud 帐户信息
【发布时间】:2014-02-12 00:20:34
【问题描述】:

如何在 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 帐户用户名,请告诉我。我已经搜索过这个,但我找不到任何适合我的案例的答案。

【问题讨论】:

  • 欢迎来到stackoverflow。这不是 Show me da codez!!! 网站。所以有些努力。如果有,请发布一些代码。
  • 我不知道代码...我已经在 google 中搜索过这个但没有解决方案...
  • 我使用它的唯一代码是使用此代码:NSURL ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; if (ubiq) { NSLog(@"iCloud 访问 %@", 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]; // [警报显示]; NSLog(@"没有 iCloud 访问权限"); } 但它返回 nil..
  • 您可以编辑您的原始问题并在其中添加您的代码,而不是在 cmets 中发布代码。
  • 感谢 devraj .....编辑我的问题...这是我第一次在 stackoverflow 中发布问题...

标签: ios xcode icloud


【解决方案1】:

你做不到。第三方应用程序无法使用 iCloud 帐户的详细信息。您所能找到的只是 iCloud 是否可用于您的应用程序。用户名不能通过任何公共 API 获得。 ubiquity 容器 URL 不编码 iCloud 用户名,NSFileManagerubiquityIdentityToken 也不编码。

【讨论】:

    猜你喜欢
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 2012-11-09
    相关资源
    最近更新 更多