Deep Linking in SwiftUI using AppDelegate Lifecycle

Hello together,
I am developing an App using SwiftUI and the (old / full) AppDelegate Lifecycle!

I want to have a deeplink, that pops up a sheet on the ContentView and provides a Value from the URL, I can use! I already got the Parsing and receiving Deep links / scheme links in the SceneDelegate and it works, but I don‘t know how to control the View(s)!

Would be soo nice, if anyone could help me :slight_smile:

Thanks!

See Handling deeplinks in iOS 14 with onOpenURL – Donny Wals

I have already read this. But I don‘t want to use the new SwiftUI lifecycle, I want AppDelegate!

You can use AppDelegate with SwiftUI lifecycle:

https://www.swiftbysundell.com/tips/using-an-app-delegate-with-swiftui-app-lifecycle/

Alternatively, try the openURL action:

https://developer.apple.com/documentation/swiftui/openurlaction#

Ok, thanks - that’s the perfect reply! Is there something like this also for the AppIcon-3D-Touch actions?

Haven't tried it myself but you should be getting callbacks in the App Delegate in this method:

https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622935-application

Apple has removed 3D touch from its newer iPhones, so I would strongly discourage you from using it in your app.

It turns out you cannot use onOpenURL with the AppDelegate lifecycle. If you try to, you will get the following warning:

[SwiftUI] Cannot use Scene methods for URL, NSUserActivity, and other External Events without using SwiftUI Lifecycle. Without SwiftUI Lifecycle, advertising and handling External Events wastes resources, and will have unpredictable results.

You should switch to the SwiftUI lifecycle and use a UIApplicationDelegateAdaptor/NSApplicationDelegateAdaptor if necessary as mentioned in the article above.

Terms of Service

Privacy Policy

Cookie Policy