1
votes

The Facebook SDK for iOS 6 mandates that you ask for Read Permissions before Publish Permissions, and suggests strongly that you only ask for Publish Permissions in context. I, however, am not using FB login for login or anything related to read permissions, I just want people to be able to publish behavior in the app.

I want to simply ask for read permissions and then immediately ask for publish permissions in the native permissions dialog. The only way I've found to do it is by modifying the FBLoginView (which is the login view that comes packaged with the app), but I want to do it my own button that, if the user is logged in, posts to FB.

This it the call I have now

[appDelegate openSessionWithAllowLoginUI:YES];

Which calls this in the delegate

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
                        @"email",
                        @"user_likes",
                        nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
                                          allowLoginUI:allowLoginUI
                                     completionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                         NSError *error) {
                                         [self sessionStateChanged:session
                                                             state:state
                                                             error:error];
                                     }];

}

How do I either modify that function OR immediately call an "openActiveSessionwithPublishPermissions" function after the read permissions are authorized?

1
refer following link page to get list of permissions for the action on Facebook. you will get your answer, good luckDipen Panchasara

1 Answers

1
votes

you could call openActiveSessionwithPublishPermissions in the openActiveSessionWithReadPermissionss completion Handler. Right after [self sessionStateChanged:session state:state error:error];

Update:

For example. I've accomplished this, the following way:

I created this method in a class that I use to manage all the facebook transactions:

- (void)attemptToConnectToFacebookForFirstTime:(void (^)(bool granted))completion
{
    ACAccountType *facebookAccountType = [accountStore
                                          accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

    // Specify App ID and permissions
    NSDictionary *options = @{
                              ACFacebookAppIdKey: @"000000000000",
                              ACFacebookPermissionsKey: @[@"email"],
                              ACFacebookAudienceKey: ACFacebookAudienceEveryone
                              };

    [accountStore requestAccessToAccountsWithType:facebookAccountType
                                          options:options 
                                       completion:^(BOOL granted, NSError *e)
     {
         // if you gotta do something here, then do it.
         // and then call the completion

         completion(granted);
     }];
}

then created this one:

- (void)connectToFacebook:(void (^)(bool granted))completion
{
    ACAccountType *facebookAccountType = [accountStore
                                          accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

    // Specify App ID and permissions
    NSDictionary *options = @{
                              ACFacebookAppIdKey: @"0000000000000",
                              ACFacebookPermissionsKey: @[@"publish_stream",
                                                          @"publish_actions"],
                              ACFacebookAudienceKey: ACFacebookAudienceEveryone
                              };

    [accountStore requestAccessToAccountsWithType:facebookAccountType
                                          options:options 
                                       completion:^(BOOL granted, NSError *e)
     {
         // do what you gotta do, and call completion
         completion();
     }];
}

and then call them this way:

[[FacebookManager sharedManager] attemptToConnectToFacebookForFirstTime:^(bool granted)
{
    if (granted)
    {
        [[FacebookManager sharedManager] connectToFacebook:^(bool granted)
        {
            // do something
        }
    }
}

My version is not using the facebook SDK, but the idea is the same.