Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal link not working if app is not installed on an iOS Device

I've implemented universal links in my application as well as server side. Everything works fine when the app is installed. If the app is not installed on the device and I click on the universal link from say notes or mail, I'm redirected to the app store from where I can download the app. On download completion however, if I click 'OPEN' in the app store page, the app delegate method below is not called:

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler

As a result, I cannot perform certain actions in response to the userActivity.webpageURL that I would normally get when the app is running or previously installed on a device. Is this normal behaviour? i.e. If the app is not installed, the Universal link will only serve as a medium to install the app from the app store?

like image 273
batman Avatar asked Nov 22 '17 12:11

batman


People also ask

Can we test universal link in iOS simulator?

xcrun supports opening URLs on iOS simulator as if they have been triggered by a user action. So if you're having all your USB ports plugged in with other stuff like me, you can test universal links on iOS simulator using xcrun!

How do I deep link an iOS app?

All you have to do is tell the app which scheme would you like to use. For this just Open Xcode, got to Project Settings -> Info, and add inside 'The URL Types” section a new URL scheme. Add something of the sort of com. myApp and that's it.

How do you implement universal links?

To support universal links in your app: Create a two-way association between your app and your website and specify the URLs that your app handles. See Supporting associated domains. Update your app delegate to respond when it receives an NSUserActivity object with the activityType set to NSUserActivityTypeBrowsingWeb .


1 Answers

That's exactly how universal links are supposed to work. If the user didn't have your app, the download is a brand new session instead of a continued user activity.

I believe branch.io offers an SDK that allows for continuity for new installs.

Edit:

Ok, I did some digging and this is called deferred deep linking. It's not officially supported by Apple Universal links.

But here's basically how branch does it:

  • When the new users visits your site, you store a unique token in the cookies for you website.
  • Then when the app is opened for the first time, you check for that token using SafariServices
  • If the token is present, run your continuity code.

Here's a more detailed article about all the linking types in iOS.

like image 106
ahbou Avatar answered Sep 19 '22 02:09

ahbou