【发布时间】:2019-03-22 22:10:33
【问题描述】:
试图通过我的应用程序弄清楚如何让应用程序知道手机何时被锁定或应用程序何时最小化并使用另一个应用程序。
这是我目前所拥有的:
//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
})
}
【问题讨论】:
-
在 appDelegate 上检查应用的后台 Stage