Native iOS Facebook SSO won't return to app
Your info.plist seems to be formatted incorrectly
Ensure that the url scheme is nested under an item (an array to be exact) called "URL Schemes"
This array should contain all possible URL Schemes that can launch your app
See the attached image for a better explanation of URL Schemes
Also, the "URL identifier" should be your bundle identifier: ex. com.mycompany.myapp This should match the identifier you provide on your provisioning profiles
hope this helps!
All you have to follow these steps
STEP 1:
Facebook developer side stuff:
If your app is already submitted then fill iphone/ipad appstore id otherwise leave it empty.
STEP 2:
Next in your XCode:
Goto
Target > Info > URL Types
> click plus icon and add the items like this-
In my application, there were both options to login via facebook and google so I created two URL Types. You can see second one are Facebook URL Type settings. URL Scheme will be your facebook app id from facebook Developer account with fb
at starts. So if your facebook developer app id is 9876543267575645
then URL Scheme will become fb9876543267575645
.
STEP 3:
Next, you have to add a new key in info.plist. So remain in same screen and add FacebookAppID
like this screen:
All this stuff will bring your app back after successful facebook oauth.
STEP 4:
Rest you will do in your AppDelegate
class. Simply add this method in AppDelegate.m
NSString *retURL = [NSString stringWithFormat:@"%@", url];
if ([retURL rangeOfString:facebookid].location != NSNotFound)
{
// if your application is coming back from facebook native app.
return [_facebook handleOpenURL:url];
}
else
{
// if your app is coming back from google plus oauth.
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
during all this, must intialise and synthesize facebook
instance in AppDelegate.m
@synthesize facebook = _facebook;
and didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_facebook = [[Facebook alloc] initWithAppId:facebookid];
// rest of your code is already here......
}
One more important thing. During I was implementing these steps, I also did too much research to achieve this and finally the working stuff is here. I made these settings in two of my apps.
But while I was creating third app, I started from beginning and did not follow STEP 1 and STEP 3 and voila.... redirection works! So i don't think facebook developer account Native iOS App settings are necessary while you are making Facebook login in your app..
I ran into another issue. I edited the raw Info.plist file and added:
<key>URL Types</key>
<array>
<dict>
<key>URL Schemes</key>
<array>
<string>fbxxxxxxxxx</string>
</array>
</dict>
</array>
That didn't work because the keys are not 'URL Types', 'URL Schemes' and 'URL Identifier', it's 'CFBundleURLTypes' , 'CFBundleURLSchemes' and 'CFBundleURLIdentifier' instead. Xcode will rename that in the editor to 'URL Types', 'URL Schemes' and 'URL Identifier'.
To be sure select the Info.plist in xcode, right click->show raw keys/values.