Bjergsen
Bjergsen

Reputation: 207

Deep linking redirect to app only works on 2nd attempt on iOS 9 and up only

I have a strange redirect to app issue with our login system in iOS 9 only.

Now, I already have abitrary payload allowed and my url schemes are setup properly in my plist file.

What happens is this:

Now, if the user closes the SFSafariViewController, comes back to our in app login page and attempt to login again a 2nd time, the redirect to the app works every time from there and the openUrl AppDelegate method is called each time.

Do note that on iOS9, we previously redirected outside the app to Safari to complete the login process (instead of using a SFSafariViewController) and had the same issue whereas the "open in App" popup to redirect to the app would only be shown on the 2nd login attempt and up.

This is all happening on iOS 9 only. On iOS 8, this issue does not appear and our users are always redirected to the app after login in.

The redirect url sent to the app after the OAuth login is the same on the first login attempt and up.

Has anyone gotten such a problem on iOS 9?

Upvotes: 14

Views: 2372

Answers (2)

Dan Leonard
Dan Leonard

Reputation: 3395

I Had experience with deep linking issues In my case the root of the problem is that we had the CFBundleIdentifier set in the info.plist to a blank String "" by deleting it or setting it to you apps name it fixed our routing issues.

Hope that helps.

Upvotes: 0

Vizllx
Vizllx

Reputation: 9246

As you have mentioned regarding Facebook, so

  1. First, guess you are missing the call of FBSDKApplicationDelegate's application:openURL:sourceApplication:annotation: from UIApplicationDelegate's application:openURL:options:

  2. You may be missing this line NSURL *url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]; in UIApplicationDelegate's didFinishLaunchingWithOptions

  3. Cross check that you have followed the setup as mentioned in this https://developers.facebook.com/docs/ios/ios9

  4. If the device is Jailbreak then in iOS 9.0.2 it will cause the url scheme issue.

Solution that worked for me is the below lines of code, as I have both FB /G+ integrated in my app same as yours:-

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
    return [[FBSDKApplicationDelegate sharedInstance] application:app
                                                          openURL:url
                                                sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                       annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]
            || [[GIDSignIn sharedInstance] handleURL:url
                                   sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                          annotation:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{

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

Upvotes: 3

Related Questions