Question

I'm using the Facebook sdk login control in my app, which is working fine as long as the user configured his Facebook account in the settings section of the iOS.

The problem is that users who didn't configure the account report they can't login.

In order to test the issue I removed my account and indeed - when trying to login I see the app is opening the Facebook App / Browser and immediately closes it and returns to the login screen.

Is there a special configuration for the login control or an alternate way to implement the login so it will support all users?

My code:

     FBLoginView *loginView = [[FBLoginView alloc] init];
    loginView.delegate=self;
    loginView.readPermissions = @[@"basic_info", @"email"];
    loginView.defaultAudience=FBSessionDefaultAudienceEveryone;


    loginView.frame = CGRectOffset(loginView.frame, (self.view.center.x - (loginView.frame.size.width / 2)), 270);
    [self.view addSubview:loginView];
Was it helpful?

Solution

Add following code to AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
     [FBLoginView class];

     return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

    [[FBSession activeSession] handleDidBecomeActive];
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    [[FBSession activeSession] close];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {

    // Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses
    BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];

    // You can add your app-specific url handling code here if needed

    return wasHandled;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top