Friday, October 9, 2026
HomeiOS Developmentswiftui - iOS Widget a number of deeplinking path utilizing widgetURL

swiftui – iOS Widget a number of deeplinking path utilizing widgetURL

[ad_1]

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

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

var physique: some View {

        HStack(alignment: VerticalAlignment.high) {
            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"))
        }
 }

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

Are there another method to obtain this please?

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

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

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments