iOS 16 Lock-screen Widget: can we add a deep link to the widget

Viewed 85

I want the user to be able to tap on a lock-screen widget created by my app and deep link to my main app (eg, so that my main app can take some action) I have been able to do this with Home Widgets, but the same method does not work with the Lock Screen widgets in iOS 16.

Is this possible? Here is a code that works for Home Widgets:

                    Link(destination: myActionURL) {
                    Image("my_image").resizable(capInsets: EdgeInsets(), resizingMode: .stretch)
2 Answers

I was able to do this using widgetURL. In the app delegate catch the url using func applicationHandle(url: URL) and do the action based on the url.

            VStack(spacing: 0) {
            Text("\(String(carName))").font(.system(size: 10)).fontWeight(.bold).minimumScaleFactor(0.4)
            Image("action").resizable(capInsets: EdgeInsets(), resizingMode: .stretch)
                .aspectRatio(contentMode: .fit).foregroundColor(entry.widgetTextColor)
        }
        .widgetURL(url)

It is my understanding that lock screen widgets are not interactive. They’re meant to show glanceable content from your app, not have tappable elements.

If you find out anything that contradicts this, I would love to hear it as I also wish to have them be tappable.

Related