正如我在指南中看到的那样,通知会自动显示。但是..不适合我。问题是为什么?当用户点击按钮时,我的 iOS 应用程序会在 4 秒后发送通知:
@IBAction func stopTimerPress(sender: AnyObject) {
print("Stop timer!")
notification.alertBody = "STOP!"
self.timer = NSTimer.scheduledTimerWithTimeInterval(4.0, target: self, selector: "fire", userInfo: nil, repeats: true)
}
然后我希望(如果 iOS 中的应用程序在后台)我的 Apple Watch 显示静态通知。但它没有发生。我能做些什么?我取消了注释:
override func didReceiveLocalNotification(localNotification: UILocalNotification, withCompletion completionHandler: ((WKUserNotificationInterfaceType) -> Void)) {
print(localNotification.alertBody)
completionHandler(.Default)
}
在 NotificationController 中,但这仍然不起作用。有人能帮我吗?