首先,我不想使用 Facebook SDK,所以我设法做到了,这是可行的,但我不知道如何检索用户的电子邮件,即使它在我的权限请求中。
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:accountTypeName];
NSDictionary *options;
if ( [accountTypeName isEqualToString:ACAccountTypeIdentifierFacebook]){
options = @{
ACFacebookAppIdKey: @"601517946570890"
,ACFacebookPermissionsKey: @[@"email"]
};
}
[account requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
_account = [arrayOfAccounts lastObject];
NSDictionary *dict = @{
@"name": [_account userFullName] == nil ? [_account username] : [_account userFullName],
@"account_id": [_account identifier],
@"email": @"??"
};
NSLog(@"account info: %@",dict);
}
}
}];
ACAccount 上没有返回用户电子邮件的属性,因此我尝试查找是否必须通过 SLRequest 完成但找不到。
可能吗?