application(app,open,options) not being called when used with @UIApplicationDelegateAdaptor

Hi there! My SwiftUI app uses @UIApplicationDelegateAdaptor to implement an AppDelegate class and I need its delegate method application(app,open,options) to be called when my Widget is tapped by the user (I'm using a small Widget with widgetURL modifier attached to its view).

The problem is: application(app,open,options) entry point in my AppDelegate class is never called.

Just for information, application(application,didFinishLaunchingWithOptions) works fine.

I've added an info.plist entry to link my app to an specific URL scheme:

Code Block language
<array>
<dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>myAppBundleId</string>
            </array>
            <key>CFBundleURLName</key>
            <string>recorder</string>
</dict>
</array>

This is the widgetURL modifier attached to the view:

Code Block language
                RecorderWidgetView()
                    .widgetURL(URL(string: "recorder://zap")!)

And this is the app delegate method that I would like to be called but it's not being called:

Code Block language
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return true
}


Is there something else I should do?

Thanks.



How were you able to test triggering application(application,didFinishLaunchingWithOptions)? When I run the widget, it's its own target and doesn't seem to trigger any breakpoints in my app delegate.
In Emoji Rangers we handle it directly on the on SwiftUI view. You shouldn't need @UIApplicationDelegateAdapter to handle the url.
Code Block swift
var body: some View {
        NavigationView {
            List {
                NavigationLink(
                    destination: DetailView(character: .panda), isActive: $pandaActive) {
                    TableRow(character: .panda)
                }
            }
            .onOpenURL(perform: { (url) in
                self.pandaActive = url == CharacterDetail.panda.url
})
        }
    }


@ricob, thank you for providing that! Extremely helpful. However this would only work with systemMedium/systemLarge Widgets - how would you go about doing this for the small widget? For context, I'm trying to track analytics to determine which Widget size our users get the most benefit from. Any ideas on how this would be possible? Thank you!
application(app,open,options) not being called when used with @UIApplicationDelegateAdaptor
 
 
Q