Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBSDKLoginManager logInWithPublishPermissions always returns isCancelled=YES

I am having trouble figuring out how to log a user into my app. [FBSDKAccessToken currentAccessToken] is nil, so I am calling:

[[[FBSDKLoginManager alloc] init] logInWithPublishPermissions:@[@"publish_actions"] handler:…]; 

as per the included sample project. This switches to the Facebook app, but the message says "You have already authorized App Name.". I click OK and it goes back into the app, but grantedPermissions and declinedPermissions are both nil on the result, and isCancelled is YES. [FBSDKAccessToken currentAccessToken] is still nil.

I can't figure out how I'm supposed to get currentAccessToken to be filled in. It seems to me the call to logInWithPublishPermissions should do that, but it isn't.

like image 533
devios1 Avatar asked Mar 31 '15 00:03

devios1


2 Answers

You should try adding in your AppDelegate didFinishLaunchingWithOptions :

return [[FBSDKApplicationDelegate sharedInstance] application:application                                     didFinishLaunchingWithOptions:launchOptions]; 

This would get u [FBSDKAccessToken currentAccessToken] when user is logged in.

and

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {     return [[FBSDKApplicationDelegate sharedInstance] application:application                                                           openURL:url                                                 sourceApplication:sourceApplication                                                        annotation:annotation]; } 

If this method is not present into AppDelegate then it results into cancelled state.

Refer to : https://developers.facebook.com/docs/ios/getting-started#startcoding

like image 148
Dheeraj Singh Avatar answered Sep 22 '22 13:09

Dheeraj Singh


This can happen when your Facebook App doesn't have "publish_actions" permission, or you're not using a test user.

On Facebook, go to manage your app, then make sure that the Facebook user you're using is defined under "Roles" as an admin or tester.

If it's not a test user or admin - Facebook will require "publish_actions" permission to be reviewed and approved before allowing your app to use it, until then you'll receive a "isCancelled=YES" result.

After testing your app with this permission, it is possible to submit this permission for review, you'll need to upload a binary that demonstrates usage of this permission with exact details on how to use it. After it's approved, you'll be able to use it with non-test Facebook users.

like image 20
Kof Avatar answered Sep 19 '22 13:09

Kof