Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK 3.0 IOS 6 callback after login not called

Second Update After doing some more digging, there seems to be a bigger issue at play.

The reason why openURL is not fired, is that the app seems to be freezing when it is brought back to the foreground.

If I launch my app, click the home button (go back to home screen), and re-load my app (not full relaunch but just a restore), the app opens, but everything is frozen.

-(void)applicationWillEnterForeground:(UIApplication *)application

is fired when the app comes back, however after that nothing happens. Using the simulator for IOS 6.0 I get no crash at all, but the app just sits there doing nothing. Click on the screen does nothing. If I click on the home screen I can go back to the home screen.

So the reason openIURL is not fired is because the app freezes when it comes back from Facebook login either from Safari or Facebook app. It has nothing to do with the facebook SDK.

Why is this happening?

Update Seems the issue is related with openURL not being called. The app does open when the custom URL is executed from safari or facebook app. If I create a brand new app it does work.

Another Related Issue application open Url method not called after user authenticates the facebook

I have an app that uses facebook login with the facebook SDK 3.0.

Under IOS 5 the flow works as intended and I do see the output of IS LOGGED IN:

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

[FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES
completionHandler:^(FBSession *session,
                    FBSessionState status,
                    NSError *error) {
    if(session.isOpen){
      NSLog(@"IS LOGGED IN");
    }                                  
}];

[permissions release];

In my App delegate the openURL function is as follows

- (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
{
    return [[FBSession activeSession] handleOpenURL:url];
}

Again, under IOS 5 the openURL function is called after a successful login through facebook.

Under IOS 6, when I execute the openActiveSessionWithPermission (login)..the openURL is never called back.

I have supplied the necessary information in my .plist file according to facebook documentation

FacebookAppID = (My Facebook App ID)

and

URL types 
 -> Item 0
    -> URL Schemes
      -> Item 0 = (My Facebook App ID)
like image 973
Heronkill Avatar asked Sep 19 '12 15:09

Heronkill


People also ask

How initialize Facebook SDK IOS?

In Xcode, click File > Swift Packages > Add Package Dependency. In the dialog that appears, enter the repository URL: https://github.com/facebook/facebook-ios-sdk. In Version, select Up to Next Major and the default option. Complete the prompts to select the libraries you want to use in your project.

What is Facebook SDK for IOS?

The Facebook SDK is what allows mobile app developers to integrate Facebook within a mobile app. SDK stands for software development kit, and it allows for a website or app to integrate with Facebook seamlessly. Examples of what you can do with Facebook SDK include: Facebook Login functionality.

Does Facebook SDK use IDFA?

The Facebook SDK includes code to access Apple's Advertising Identifier (IDFA), but that code is only executed in certain situations.


2 Answers

Could this possibly be because your app is set to not run in the background, as set in your app plist? I have been having this same problem. It seems that, if the app is left running in the background, it will return and call openURL. But if the app does not run in the background, it will return and call application:didFinishLaunchingWithOptions instead, and NOT call openURL. It is possible to get the url from the launch options:

NSURL *url = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey];

but I have not figured out how to call this so that it has the same effect as application:openURL when returning from Facebook authentication. Hope this helps some.

like image 163
SAHM Avatar answered Oct 13 '22 01:10

SAHM


The issue was related to the way I was using TWTweetComposeViewController in my app, so it is not related to facebook SDK afterall.

The issue was that I was initializing my TWTweetComposeViewController in my ViewDidLoad and not using until needed. However, if the TWTweetComposeViewController is not shown but is initiliazed, it will freeze your application when it enters from background mode.

The fix is to initiliaze TWTweetComposeViewController only when you are about to show it.

like image 26
Heronkill Avatar answered Oct 12 '22 23:10

Heronkill