Native iOS Facebook SSO won't return to app

前端 未结 4 1947
孤独总比滥情好
孤独总比滥情好 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:28

    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.

    enter image description here

    0 讨论(0)
  • 2020-12-06 11:37

    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!

    0 讨论(0)
  • 2020-12-06 11:38

    None of the above, or other answers on SO, worked for me, though I seemed to have the exact same issue.

    However, when I enabled "Deep Linking", it worked perfectly, so it may have been a combination of all of the above AND enabling that option too.

    0 讨论(0)
  • 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..

    0 讨论(0)
提交回复
热议问题