Sunday, November 27, 2022
HomeiOS Developmentswiftui - iOS Widget a number of deeplinking path utilizing widgetURL

swiftui – iOS Widget a number of deeplinking path utilizing widgetURL


I’ve a .systemMedium widget. There are 2 vstack to navigate to completely different view within the app (view deep linking)

The issue is once I press the primary vstack, it stored on redirecting to the Button2Path as an alternative of Button1Path:

var physique: some View {

        HStack(alignment: VerticalAlignment.prime) {
            Spacer()

            VStack {
                Button {
                    print("button 1 was tapped")
                } label: {
                    Picture("BtnView1")
                }
                Textual content("button 1")
            }.widgetURL(URL(string: "testApp://Button1Path"))

            Spacer()

            VStack {
                Button {
                    print("button 2 was tapped")
                } label: {
                    Picture("BtnView2")
                }
                Textual content("button 2")
            }.widgetURL(URL(string: "testApp://Button2Path"))
        }
 }

Test the docs on widgetURL it says “Units the URL to open within the containing app when the consumer clicks the widget.”

Are there another approach to obtain this please?

Is it by utilizing Hyperlink? the way to use it with Vstack?

    Hyperlink(vacation spot: URL(string: "testApp://Button1Path")!) {
        Textual content("Hyperlink 1")
    }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments