# Deep Linking in SwiftUI using AppDelegate Lifecycle

**URL:** <https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201>\
**Category:** Using Swift\
**Tags:** off-topic, swiftui, url\
**Created:** [September 19, 2021, 5:16pm UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201 "2021-09-19T17:16:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jannis6023](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jannis6023/32/19529_2.png) [@Jannis6023](https://forums.swift.org/u/Jannis6023)\
**Post date:** [September 19, 2021, 5:16pm UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/1 "2021-09-19T17:16:58Z")

</div>

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 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![Peter-Schorn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/peter-schorn/32/11183_2.png) [@Peter-Schorn](https://forums.swift.org/u/Peter-Schorn)\
**Post date:** [September 19, 2021, 8:21pm UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/2 "2021-09-19T20:21:45Z")

</div>

See [Handling deeplinks in iOS 14 with onOpenURL – Donny Wals](https://www.donnywals.com/handling-deeplinks-in-ios-14-with-onopenurl/)

---

<div class="post-metadata">

**Author:** ![Jannis6023](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jannis6023/32/19529_2.png) [@Jannis6023](https://forums.swift.org/u/Jannis6023)\
**Post date:** [September 19, 2021, 8:37pm UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/3 "2021-09-19T20:37:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![handmadeapps](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/handmadeapps/32/19645_2.png) [@handmadeapps](https://forums.swift.org/u/handmadeapps)\
**Post date:** [September 20, 2021, 4:58am UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/4 "2021-09-20T04:58:58Z")

</div>

You can use AppDelegate with SwiftUI lifecycle:

[https://www.swiftbysundell.com/tips/using-an-app-delegate-with-swiftui-app-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#](https://developer.apple.com/documentation/swiftui/openurlaction#)

---

<div class="post-metadata">

**Author:** ![Jannis6023](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jannis6023/32/19529_2.png) [@Jannis6023](https://forums.swift.org/u/Jannis6023)\
**Post date:** [September 20, 2021, 6:37am UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/5 "2021-09-20T06:37:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![handmadeapps](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/handmadeapps/32/19645_2.png) [@handmadeapps](https://forums.swift.org/u/handmadeapps)\
**Post date:** [September 20, 2021, 8:26am UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/6 "2021-09-20T08:26:02Z")

</div>

> [@Jannis6023](#):
>
> AppIcon-3D-Touch

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](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622935-application)

---

<div class="post-metadata">

**Author:** ![Peter-Schorn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/peter-schorn/32/11183_2.png) [@Peter-Schorn](https://forums.swift.org/u/Peter-Schorn)\
**Post date:** [September 21, 2021, 8:11pm UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/7 "2021-09-21T20:11:10Z")

</div>

> [@Jannis6023](#):
>
> Is there something like this also for the AppIcon-3D-Touch actions?

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

---

<div class="post-metadata">

**Author:** ![Peter-Schorn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/peter-schorn/32/11183_2.png) [@Peter-Schorn](https://forums.swift.org/u/Peter-Schorn)\
**Post date:** [September 21, 2021, 8:15pm UTC](https://forums.swift.org/t/deep-linking-in-swiftui-using-appdelegate-lifecycle/52201/8 "2021-09-21T20:15:23Z")

</div>

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.
