iosfacebookacaccountstore

Logging between two Facebook accounts using ACAccountStore IOS


Ok so I have been using SLRequest to Facebook in my app. Question seems relatively simple and I partially know whats wrong but can't find the fix through a few hours of searching.

-I login to Facebook via the device settings only, never in my App itself.

-The app has the popup to give permission to publish, and works just as intended.

-I logout of Facebook in settings and log in to another Facebook account and here is where the issue is. It will NEVER get passed granted in the app (code below) when logged in with the second account.

-I can log back in with the First account in settings and the app continues to post perfectly well as intended.

-I understand you can have only 1 FB account in the store, surely there must be someway to reset it to allow the app to post from an account other than the initial one I used??

Any help would be appreaciated.

- (void)shareSessionToFacebook {
        // Specify App ID and permissions
        NSDictionary *options = @{ACFacebookAppIdKey: @“XXXXXXXXXXXXX”,
        ACFacebookPermissionsKey: @[@"email", @"publish_stream", @"publish_actions"],
       ACFacebookAudienceKey: ACFacebookAudienceFriends};
        accountStore = [[ACAccountStore alloc]init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error) {
        if (granted) {

Solution

  • I stumbled back around onto my answer. Regarding logging using just the settings menu of the device as I am doing, on any first login, you must request the email, (or one of a few others) ALONE on the first call, after that you can request the varios publish_ permissions......

    So on the initial login, or switching to another account just use email, then make a second request for your publish, etc permissions..

    //INITIAL LOGIN START//
    NSDictionary *optionsX = @{
                               ACFacebookAppIdKey: @"XXXXXXXXXXXXXX",
                               ACFacebookPermissionsKey: @[@"email"],
                               ACFacebookAudienceKey: ACFacebookAudienceFriends
                               };
    ACAccountStore *accountStoreX = [[ACAccountStore alloc]init];
    ACAccountType *accountTypeX = [accountStoreX accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    [accountStoreX requestAccessToAccountsWithType:accountTypeX options:optionsX completion:^(BOOL granted, NSError *error) {
        if (granted) {
            NSLog(@"ALPHA GRANTED!!!!");
        } else {
            NSLog(@"ALPHA NOT GRANTED");
        }
    }];
    //INITIAL LOGIN END//