我使用社交框架登录Facebook并成功获得了令牌。您知道如何将其设置为Facebook FBsession
中的SDK
吗?我想用这个令牌进行会话,然后将其设置为FBSession.activeSession
,所以一切都是同步的:)。
谢谢你们。
ACAccountType *facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = @{
@"ACFacebookAppIdKey" : @"123456789",
@"ACFacebookPermissionsKey" : @[@"publish_stream"],
@"ACFacebookAudienceKey" : ACFacebookAudienceEveryone}; // Needed only when write permissions are requested
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:options
completion:^(BOOL granted, NSError *error) {
if (granted)
{
NSArray *accounts = [self.accountStore
accountsWithAccountType:facebookAccountType];
self.facebookAccount = [accounts lastObject];
ACAccountCredential *facebookCredential = [facebookAccount credential];
NSString *accessToken = [facebookCredential oauthToken];
} else {
NSLog(@"%@",error);
// Fail gracefully...
}
}];