iphone – 从iOS中的ACAccountStore获取Facebook uid?
发布时间:2020-12-14 19:50:30 所属栏目:百科 来源:网络整理
导读:嗨,我想从iOS 6中的ACAccountStore获取Facebook用户的UID self.accountStore = [[ACAccountStore alloc]init]; ACAccountType *FBaccountType= [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; NSString *key =
嗨,我想从iOS 6中的ACAccountStore获取Facebook用户的UID
self.accountStore = [[ACAccountStore alloc]init]; ACAccountType *FBaccountType= [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; NSString *key = @"01234567890123"; NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:key,ACFacebookAppIdKey,@[@"email"],ACFacebookPermissionsKey,nil]; [self.accountStore requestAccessToAccountsWithType:FBaccountType options:dictFB completion: ^(BOOL granted,NSError *e) { if (granted) { NSArray *accounts = [self.accountStore accountsWithAccountType:FBaccountType]; //it will always be the last object with single sign on self.facebookAccount = [accounts lastObject]; //i Want to get the Facebook UID and log it here NSLog(@"facebook account =%@",self.facebookAccount); } else { //Fail gracefully... NSLog(@"error getting permission %@",e); } }]; self.facebookAccount有UID,但我无法得到它 解决方法
我想获得UID而不使用Facebook API.可以使用以下方法完成
self.accountStore = [[ACAccountStore alloc]init]; ACAccountType *FBaccountType= [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; NSString *key = @"01234567890123"; NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:key,NSError *e) { if (granted) { NSArray *accounts = [self.accountStore accountsWithAccountType:FBaccountType]; //it will always be the last object with single sign on self.facebookAccount = [accounts lastObject]; //i got the Facebook UID and logged it here (ANSWER) NSLog(@"facebook account =%@",[self.facebookAccount valueForKeyPath:@"properties.uid"]); } else { //Fail gracefully... NSLog(@"error getting permission %@",e); } }]; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |