gpt4 book ai didi

iphone - 从 ACAccountStore 在 iOS 中获取 Facebook uid?

转载 作者:行者123 更新时间:2023-11-30 05:18:17 25 4
gpt4 key购买 nike

您好,我想从 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,但我无法获取它...

最佳答案

我想在不使用 Facebook API 的情况下获取 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 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 - 从 ACAccountStore 在 iOS 中获取 Facebook uid?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14951984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com