Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • A user is brought to an SFSafariViewController to login with facebook/google
  • The user enters his credentials (or not if they are already cached)
  • Instead of being redirected to our app, the user is then stuck on a blank page if his credentials are cached, or stuck on the final google/facebook login page. No "open in app" dialog appears and the openUrl AppDelegate function is not called.

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?

like image 464
Bjergsen Avatar asked Jan 27 '16 20:01

Bjergsen


People also ask

How do universal links work iOS?

Universal links are available in iOS version 9 and above, and work even when the app isn't installed on a user's device. When tapping a link to your website without the app installed, the user will then be linked to your website in Safari. So, both your website and your app work for one URL.

What is deeplink redirect?

Deep links send mobile device users directly to relevant pages in your app rather than your website. Users click on ads and go directly to your app pages. You can use deep links in many Google Ads products, including App campaigns for engagement, App dynamic remarketing, and Search, Shopping, and Display campaigns.


1 Answers

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];
   }
like image 162
Vizllx Avatar answered Oct 06 '22 02:10

Vizllx