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)
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)