I'm trying to implement a lock screen in the SwiftUI app.
I need to track every event in order to restart the lock timer.
In UIKit app, I used this approach - overriding UIApplication, which allows being aware of any event across the app:
override func sendEvent(_ event: UIEvent) {
super.sendEvent(event)
switch event.type {
case .touches:
// Post Notification or Delegate here
default:
break
}
}
But in SwiftUI it is not supported anymore. I tried to add
.onTapGesture {}
to the root ContentView, but it doesn't work as expected.
Is there any way to avoid adding
.onTapGesture {}
to every single view in the app?