如何将Facebook帐户导出到“设置”

时间:2012-12-23 19:59:19

标签: ios facebook acaccount

使用发布权限成功登录后,无法将Facebook帐户导出到系统帐户存储。有什么建议吗?

NSString* refreshToken = nil;
NSString* accessToken = [[FBSession activeSession]accessToken];
NSDate* expiryDate = [[FBSession activeSession]expirationDate];
NSString* appId = [FBSession defaultAppID];

ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *fbType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

NSDictionary *options = @{
ACFacebookAppIdKey: appId,
ACFacebookPermissionsKey:  @[@"publish_stream"],
ACFacebookAudienceKey: ACFacebookAudienceEveryone
};

ACAccount *fbAccount = [[ACAccount alloc] initWithAccountType:[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]];

ACAccountCredential *outhCredential = [[ACAccountCredential alloc] initWithOAuth2Token:accessToken refreshToken:refreshToken expiryDate:expiryDate];

fbAccount.credential = outhCredential;

[store saveAccount:fbAccount withCompletionHandler:^(BOOL success, NSError *error) {

    if(success)
    {
        NSLog(@"Success");
    }

    return;
}];

0 个答案:

没有答案