我们正在使用WatchOS 3.0提供的UNUserNotification框架来创建本地通知,以便在预定义时刻通知用户。但是,当手表未戴在手腕上时,不会显示通知。当有人穿着它时,它确实很有效。
我们无法在任何文档中找到此说明。这是正常的吗?如果是,如何帮助用户避免错过一些通知?
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
// Enable or disable features based on authorization.
if granted {
let content = UNMutableNotificationContent()
content.title = title
content.body = body
content.sound = UNNotificationSound.default()
content.userInfo = userInfo
let trigger = UNTimeIntervalNotificationTrigger.init(
timeInterval: interval,
repeats: false)
let identifier = stringWithUUID()
let request = UNNotificationRequest.init(
identifier: identifier,
content: content,
trigger: trigger
)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
completion?(true, nil)
}
else {
completion?(false, error)
}
}
答案 0 :(得分:2)
这是正常现象,当您将手机从手腕上取下时,Apple Watch会自动锁定并通知您的iPhone。