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); } }];总结
以上是内存溢出为你收集整理的iphone – 从iOS中的ACAccountStore获取Facebook uid?全部内容,希望文章能够帮你解决iphone – 从iOS中的ACAccountStore获取Facebook uid?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)