3

Cannot export Facebook account to System accounts storage after successful login with publish permissions. Any suggestions?

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;
}];
  • Did you ever manage to resolve this? I'm having the same problem and I can't seem to find out how to do this anywhere! – Chris Grant Mar 11 '13 at 00:21

0 Answers0