Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBSDK (New Facebook SDK 4.0) Implementation is not working for Login with Facebook

I am using this following block which is mentioned in Facebook Developer. But when my App callbacks from Browser then it is always returning Cancelled result.

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"]     
        handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
  if (error) {
        // Process error
   }
  else if (result.isCancelled) {
        // Handle cancellations
   }
   else {
       // If you ask for multiple permissions at once, you
       // should check if specific permissions missing
       if ([result.grantedPermissions containsObject:@"email"]) {
        // Do work
       }
  }
 }];

this update comes on 25 March 15,

If anyone used this then please share it with me.

Reference : https://developers.facebook.com/docs/ios/getting-started

like image 277
Sarat Patel Avatar asked Mar 31 '15 07:03

Sarat Patel


People also ask

What is the latest Facebook SDK version?

The current version of the Facebook SDK for Android is version 14.1. 0 and requires the Android API 15. Code and samples for the Facebook SDK for Android are available on GitHub.

How do I update my Facebook SDK?

Login into Facebook and navigate to https://developers.facebook.com/apps/ Select the App you want to upgrade (you might have access to multiple apps) Click Settings > Advanced. Select the latest version under the Upgrade API Version section for both “Upgrade All Calls” and “Upgrade Calls for App Roles”


1 Answers

You must add the following method in your appDelegate

- (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 the above 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 73
Dheeraj Singh Avatar answered Oct 21 '22 20:10

Dheeraj Singh