Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBAppCall removed from Facebook update 4.x - return to app after Facebook login

Since the update to Facebook 4.x, the following no longer works:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [FBAppCall handleOpenURL:url sourceApplication:@"yyyyxxxxyyyxxxx" withSession:[PFFacebookUtils session]];
}

as both application: handleOpenURL has been deprecated, and FBAppCall has been removed to be replaced with BFURL.

I've tried reading the Bolts documentation which suggests the following:

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

    BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];

//do something with parsedUrl if neccessary

...but then I'm not sure what to do with the BFURL. Previously, this method just contained:

return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                              openURL:url
                                                    sourceApplication:sourceApplication
                                                           annotation:annotation];
    }

but now every time I try to login to FB (w/o the FB app installed), it exits to Safari, approves the app, returns to my app, but reboots it, and fails to log in. After about 4 successive tries, it sometimes logs in. I presume this is because I'm not correctly handling the return to the app, but not sure what to add.

like image 704
Smikey Avatar asked Sep 28 '22 08:09

Smikey


1 Answers

Replace the old return with this:

return [[FBSDKApplicationDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationLaunchOptionsSourceApplicationKey] annotation:options[UIApplicationLaunchOptionsAnnotationKey]];
like image 71
Iulian Onofrei Avatar answered Oct 16 '22 23:10

Iulian Onofrei