7

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?

batman
  • 1,937
  • 2
  • 22
  • 41
  • this one may be an [interesting article](https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html) _(source: Apple)_ for your issue, that is about how you could handle universal link support on the server-side via _association_ files. – holex Nov 29 '17 at 09:26

2 Answers2

11

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.

Community
  • 1
  • 1
ahbou
  • 4,710
  • 23
  • 36
  • Hmm. While that does make sense it'd be nice to have an option to have continuity. Apart from Branch, any suggestions how one might implement this? I know for a fact that the behavior described above doesn't occur on Android albeit its a different ecosystem :( – batman Nov 22 '17 at 16:02
  • @akdsouza there is a way (hack?) to do this. Check my edited answer. – ahbou Nov 22 '17 at 21:55
  • thanks @ahbou it certainly seem like a hack. +1 for the effort. Will mark the answer as accepted if no other non hacky solution is posted. – batman Nov 23 '17 at 04:14
  • 2
    Another provider that does deferred deep linking is Firebase Dynamic Links. About cookie approach you mentioned: iOS 11 disallowed sharing cookies between Safari and SFSafariViewController. – Oleksiy Ivanov Nov 26 '17 at 21:22
  • I see recent documentation that Firebase Dynamic Links is being deprecated: https://firebase.google.com/support/dynamic-links-faq?hl=en&authuser=0 “Firebase Dynamic Links is no longer recommended for new projects. In the future, the Dynamic Links service will shut down, but you will have at least 12 months from the announcement date to migrate. Around the end of Q2-2023, we will announce more information.” – Chris Prince May 19 '23 at 19:44
9

The only way you can achieve this is through device fingerprinting mechanism. This is how providers like Branch, Adjust, GetSocial, Appsflyer, Tune, Kochava etc perform contextual deeplinking, deferred deeplinking, attribution, and tracking.

If you don't want to use any of the providers mentioned above, and if you just want a very basic device fingerprinting mechanism then you can do so by using only IP address. This is a very nice article from Tune on different methodologies used for attribution.

(Disclaimer: I am the founder of GetSocial)

Viral
  • 391
  • 1
  • 6