Trying to figure out, with my app, how to make the app know when the phone is locked or when the app is minimized and using another app.
This is what i have so far:
//warning notification
func warningNotification() {
let content = UNMutableNotificationContent()
content.title = "Go back to app immediately to prevent"
// content.body = publictime
// print("Notification timer\(content.body)")
content.badge = 1
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1,
repeats: false)
let requestIdentifier = "demoNotification"
let request = UNNotificationRequest(identifier: requestIdentifier,
content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request,
withCompletionHandler: { (error) in
// Handle error
})
}