Yes, as said above you can get the referrer url through an NSUserActivity
via the referrerURL
.
But you may found nil
values for this referrerURL
depending the referrer policy established by the website you used for the redirection.
To understand we need to have a look at the Referrer policies. These policies are used to secure the way of how the referrer urls are passed from a website A to another website B.
For example in some cases, website A don't want that website B be able to get the details parameters of the referrer URL so they can defined a particular type of policy. Sometimes they can completely make the referrer url null
to website B by setting the no-referrer
policy type for example.
This policy is defined into an HTTP header named Referrer policy
and currently by default have the following type: strict-origin-when-cross-origin
. You can check actually what policy is used by the source website by opening the inspector console > network > select the website url and check the Referrer policy
HTTP header.
You can have a look at the different kinds of policies and what rules they apply here
For example in our case, we were not able to get the referrer URL using the safari top banner that allows users to be redirected into our app. But using a specific link such as a link from Twitter or Slack or whatever, was providing a referrer URL.