Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

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 ?

question from:https://stackoverflow.com/questions/65601013/swiftui-small-widget-is-not-opening-the-ios-app-on-tap

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...