Search code examples
swiftuiwidgetios14widgetkit

SwiftUI small widget is not opening the iOS app on tap


In my widget, I place a header view.

   var header: some View {
        ZStack {
           Link(destination: url) {
              Rectangle().fill(Color("WidgetBackground")).frame(height: 36)
              Text("Header")
           }
        }
    }

This is a simple text on a colored background.

The url is the urlscheme for my app.

When I tap on the label or on header view, it opens my app on medium and large size widgets.

But on the small size widgets, it didnt open the app, but it flickers and reload the widget.

I also see the flicker happen in medium and large size widgets when I tap on empty spaces other than elements.

I have no clue , why this flicker happens.

Based on documentation, interacting on widget should open the app, without any extra effort.

Am I missing something ?


Solution

  • I don’t know why the app doesn’t open (an iOS bug, I guess), but your deeplink won’t work because Link isn’t available in the “small” widget size. You need to set the .widgetURL() modifier on your view instead.