Unable to post status update from ios app

89 views Asked by At

I am trying to post a status on my account. I have been trying since couple of hours but can't get it working.

- (void) shareStatusUpdateButtonClicked {
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/feed" parameters: @{ @"message" : @"hello world"}HTTPMethod:@"POST"]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
  if (!error) {
    NSLog(@"POST ID: %@",result);
  }
}];
}
else {
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithPublishPermissions:@[@"publish_actions"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
  if (!error) {
     NSLog(@"Permission  Granted");
     NSDictionary *params = @{@"message": @"This is a test message"};
     FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];
     [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,id result,NSError *error) {
       if(!error){
         NSLog(@"RESULT %@",result);
         NSLog(@"POSTED !");
       }
     }];
   }
   else{
     NSLog(@"ERROR PERMISSION NOT GRANTED");
   }
                                  }
 ];
}
}

The problem is when i run the app, it checks if the user has permitted 'publish_actions' in the if expression, it fails then the else block executes, however it displays you have already authorised this app. Then i click Ok but the status is not posted on my facebook profile. I don't understand where i am going wrong. Any help would be apperiated. PS: I have not asked the user to grant 'publish_actions' permission anywhere else in the code. Also i tried removing the app from facebook setting but it did't help.

0

There are 0 answers