Domanda

I have faced an issue in facebook SDK.

if I remove facebook account from System Preferences/Facebook and after that I try to login with facebook then it will redirect me to safari of facebook native application and I can logged in.

But when I add facebook account in System Preferences/Facebook and after that I try to login with facebook then it will not redirect me and give popup "Your app" would like to access your basic info and list of friends. and I allows to it. but FBSessionStatus always failed and I cannot logged in.

I have try to search much but not get solution for it.

I have use latest facebookSDK.

my code for login is below

    NSArray *permissions = [[NSArray alloc] initWithObjects:@"email",nil];

    // Attempt to open the session. If the session is not open, show the user the Facebook login UX

    [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:true
                                  completionHandler:^(FBSession *session,
                                                      FBSessionState status,
                                                      NSError *error)
     {
         NSLog(@"Running completion handler");

         if (status == FBSessionStateClosedLoginFailed || status == FBSessionStateCreatedOpening) {
             NSLog(@"Unable to activate Facebook Session");
         }
         else {
             NSLog(@"Logged in via facebook.  Requesting User Information.");
         }
     }];

and in AppDelegate.h

@property (strong, nonatomic) FBSession *fbsession;

AppDelegate.m

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [FBSession.activeSession handleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    NSLog(@"AppDelegate is attempting to extract Facebook token from URL");
    return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication withSession:self.fbsession];
}

I get log every Time as below

AppDelegate is attempting to extract Facebook token from URL
Unable to activate Facebook Session

Please help me to solve this issue. Thanks in advance.

È stato utile?

Soluzione

I found my Solution by adding bundle identifier in facebook app on developer.facebook.com (make iOS native app)

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top