Native iOS Facebook SSO won't return to app

前端 未结 4 1971
孤独总比滥情好
孤独总比滥情好 2020-12-06 11:25

Ok this may seem like a duplicate but I\'ve been through all of the questions that center around the issue and I still can\'t seem to get this to work for my app.

I

4条回答
  •  囚心锁ツ
    2020-12-06 11:54

    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. facebook developer account app id settings

    STEP 2:

    Next in your XCode:

    Goto Target > Info > URL Types > click plus icon and add the items like this- URL Scheme settings

    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: info.plist settings

    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..

提交回复
热议问题