Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get referrer string for Universal Link?

I implemented Universal Links in our iOS 9 app and they work by calling a method in AppDelegate.swift, in which I get an NSUserActvity with an URL attached to it.

Is there a way to get the (HTTP-) referer? I need to know on which website the user has tapped the link that opened the app.

like image 705
scrrr Avatar asked Nov 12 '15 14:11

scrrr


People also ask

How do I find my referrer URL?

Just put a summary, upon reaching the destination page, in the developer console, just type document. referrer , and you'll get the referrer URL as shown below.

What is the difference between universal link and deep link?

When an Universal Link and App Link is clicked, the operating system detects whether the app is installed on a user's device. If the app is installed, the link will immediately direct the user to the app. This is called deep linking.

What is an universal link?

What are 'Universal Links'? Universal links are Apple's way of launching apps on their operating system from a website, also known as a web view. They link to content inside an app or website, giving iOS users an integrated mobile experience.


2 Answers

I found another interesting solution if you need to support iOS 9 and 10 - https://appmetrica.yandex.com/blog/referrer-based-tracking-dlya-ios-tochnaya-atributsiya-dlya-lyubogo-istochnika-trafika.

Since iOS 11 I guess can be used NSUserActivity > referrerURL.

In short:

  • SFSafariViewController uses the same cookies as Safari app.
  • You can open invisible SFSafariViewController inside your app.
  • If your site contains some cookie - use Universal Link to pass it back to the app.

Though it requires to implement something like tracking link on your site.

like image 58
Mikhail Avatar answered Oct 18 '22 21:10

Mikhail


No, there is no way to get the referrer. An Apple employee made that pretty clear on the developer forums: https://forums.developer.apple.com/thread/65423

They say that the only way to get some kind of referrer would be to append it to the URL. Maybe take a look Google's campaign tracking URLs (utm_...).

like image 43
Cornelius Avatar answered Oct 18 '22 21:10

Cornelius