iOS Deeplink Referring URL

We have the deep_link_received event implemented using the “openURL” function however the context is only capturing the URL that the person clicked on. We’d like to capture the referring URL as well. We’ve looked at the documentation and noticed that the userActivity class is needed.

We’ve implemented it as outlined in the documentation, but we cannot get the “userActivity” function to fire when the app is launched and capture the referring url since the “userActivity” class is not used anywhere else in our app.

Any help would be appreciated .

Hi @ks107,

Thank you for the question. If I understand correctly, you are working with an app with a SwiftUI application lifecycle. It is true that our documentation is lacking information how to track deep links in this case, we will work on adding instructions for this.

In the meantime, you might be able to make use of the
onContinueUserActivity handler which can be set up to listen for web clicks and receives a NSUserActivity object (which should contain the referrerURL property), see the documentation here: onContinueUserActivity(_:perform:) | Apple Developer Documentation. Something like this might work for you (requires some testing):

ContentView()
   .onContinueUserActivity(NSUserActivityTypeBrowsingWeb, perform: { userActivity in
       // retrieve the userActivity.referrerURL
   }) 
2 Likes

Hi @matus thanks for the reply and appreciate any updates you can make to the documentation clearer. The app is in Objective C. It seems the userActivity is continuing to return null and therefore the referrerURL is not available.