Using the UIKit application lifecycle and this delegate method
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
I can access options associated with a user tapping on a custom URL. In particular I can access the bundle ID of another app of mine that triggered a custom URL to launch the target app via this property:
https://developer.apple.com/documentation/uikit/uiapplication/openurloptionskey/1623128-sourceapplication
When I output the "options" parameter after triggering I can see the bundle ID clearly for UIApplicationOpenURLOptionsSourceApplicationKey:
options: [__C.UIApplicationOpenURLOptionsKey(_rawValue: UIApplicationOpenURLOptionsSourceApplicationKey): COM.MYDOMAIN.TestURL2, __C.UIApplicationOpenURLOptionsKey(_rawValue: UIApplicationOpenURLOptionsOpenInPlaceKey): 0]
However, when using the SwiftUI application lifecycle the above app delegate function is not called in favor of the SwiftUI view extension:
onOpenURL(perform action: @escaping (URL) -> ()) -> some View
This has only the custom URL and no other options and thus I cannot find a way to find out which of my other apps triggered the target app via a custom URL.
Does anyone know if there's a way to get this information in an app that uses the SwiftUI app lifecycle or is it not available except in an app that uses the UIKit application lifecycle?
Topic:
UI Frameworks
SubTopic:
SwiftUI