Вопрос

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) {
Это было полезно?

Решение 2

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//

Другие советы

you can get the available accounts first try this for twitter you can get multiple accounts but face book only one account


   [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
  {
    if (granted == YES)
    {
     // Populate array with all available accounts only for twitter accounts not for Facebook
        NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType]; //type of twitter as your case and you will get all the availble twitter accounts
        if ([arrayOfAccounts count] > 0)
         {
           //use the first account available
           ACAccount *acct = [arrayOfAccounts objectAtIndex:0]; //select the account based on the array index


hope this helps u .. :)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top