Question

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)
Was it helpful?

Solution 2

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.

OTHER TIPS

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.

this is Shireesh from Facebook. Can you please file a bug at our developers website for this so that we can have a detailed look at it. Please make sure to provide detailed repro steps and attach screenshot if possible. https://developers.facebook.com/bugs

I set up two suffixes under Facebook for my app: free and paid such as fbxxxxxxpaid

They work perfectly fine under SDK 2.0 but in 3.2 my app was not called back and I got stuck with an the empty canvas with a cancel button.

I removed the suffix from the URL Schemes and it worked instantly.

I had to update my app according to this https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top