是否可以获取当前登录到设备的用户的Apple ID?实际上,我实现了inapp购买,并且在用户购买应用时获得了设备ID和用户的Apple ID。
我正在尝试使用CloudKit查找用户记录ID.我已经确认帐户状态是CKAccountStatusAvailable.然后我试试这个:
[[CKContainer defaultContainer] fetchUserRecordIDWithCompletionHandler:^(CKRecordID *recordID, NSError *error) {
if (error == nil) {
NSLog(@"Got user record ID (no permission req): %@", recordID);
} else {
NSLog(@"Couldn't get user record ID, error=%@", error);
}
}];
Run Code Online (Sandbox Code Playgroud)
这不可避免地失败,结果如下:
(lldb) po error
<CKError 0x608000043990: "Not Authenticated" (9/1004); "Account couldn't get container scoped user id, no underlying error received">
(lldb) po [error userInfo]
{
NSDebugDescription = "CKInternalErrorDomain: 1004";
NSLocalizedDescription = "Account couldn't get container scoped user id, no underlying error received";
NSUnderlyingError = …Run Code Online (Sandbox Code Playgroud)