1

I am trying to share on Facebook. But every time it request permission to publish, it will direct a screen "You have authorized to the "AppName"". When I click on OK. It brought me to blank screen.

Here is my flow. 1. Login to Facebook 2. Request for publish permission. 3. Publish to Facebook wall.

 [FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
                                      defaultAudience:FBSessionDefaultAudienceFriends
                                    completionHandler:^(FBSession *session, NSError *error) {
                                        if (!error) {
                                            // Now have the permission
                                            [self publishStory];
                                        } else {
                                            // Facebook SDK * error handling *
                                            // if the operation is not user cancelled
                                            if (error.fberrorCategory != FBErrorCategoryUserCancelled) {
                                                [self presentAlertForError:error];
                                            }
                                        }
                                    }];
user1302602
  • 419
  • 2
  • 6
  • 16

1 Answers1

0

You can do like this,

while opening the session specify permission to publish post

   NSArray  *permissions = [[NSArray alloc] initWithObjects:@"publish_actions",@"publish_stream",nil]; //permissions
  return [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session,FBSessionState state,NSError *error)


and whenever you want to publish, do like this


  NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:TextView.text, @"message",nil]; // set the formats
if([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound)
{
    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
     {
         NSString *alertText;
         if(error)
         {
              //if error occurred

         }
         else
         {
             //successfull
         }

     }];

    }

 }


Shankar BS
  • 8,394
  • 6
  • 41
  • 53