SwiftUI `onOpenURL` lacks `referrerURL` and `annotation` present in NSUserActivity

Hello, I am working on an application that utilizes both AppDelegate and SceneDelegate. We are looking to convert the top level app to SwiftUI and start using the SwiftUI App lifecycle. When implementing, I see that deep links when the app is backgrounded will only route to the onOpenURL modifier. This means that information we relied on before like referrerURL and annotation present in the NSUserActivity object delivered to the app is no longer available. Is there any work around for this? It seems like missing functionality because there is no way to route the deep links through AppDelegate or SceneDelegate if you are using the SwiftUI App protocol.

Answered by Vision Pro Engineer in 788545022

This is not available when using the SwiftUI life cycle because all universal links are routed through onOpenURL. If you or anyone coming across this post in the future would like to see this functionality, please submit an enhancement report at https://feedbackassistant.apple.com and post the FB number here in the comments. Thank you!

This is not available when using the SwiftUI life cycle because all universal links are routed through onOpenURL. If you or anyone coming across this post in the future would like to see this functionality, please submit an enhancement report at https://feedbackassistant.apple.com and post the FB number here in the comments. Thank you!

Thank you, here is the FB number: 13818612

Me too! FB15107497

Hi @hotngui ,

one way that you can work around this that @savasosa actually brought to my attention is to use SceneDelegate to present a SwiftUI view and then intercept the url through the scene and app delegate methods and get the referrerURL. If you use SwiftUI, as I mentioned above, onOpenURL will not give you the rerrerURL, but using the SceneDelegate route means the URL shouldn't go to the onOpenURL method and you can instead handle it as shown here: https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app

SwiftUI `onOpenURL` lacks `referrerURL` and `annotation` present in NSUserActivity
 
 
Q