I intend to use the code below to send a notification from hosing iOS app to Apple Watch app
我打算使用下面的代码从iOS应用程序发送通知到Apple Watch应用程序
var localNotification = UILocalNotification()
localNotification.fireDate = NSDate()
localNotification.alertBody = ""
localNotification.alertAction = ""
localNotification.category = "GameStart"
localNotification.userInfo = payload.toDictionary() as [NSObject : AnyObject]
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
UIApplication.sharedApplication()。scheduleLocalNotification(localNotification)
according to https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html, the Watch App should receive the notification under certain circumstances, I tried - lock the screen - put iOS app into background
根据https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html,Watch App应该在某些情况下收到通知,我试过 - 锁定屏幕 - 放iOS应用程序到背景
But the Watch App never receive any notifications from iOS app.
但Watch App从未收到iOS应用程序的任何通知。
1 个解决方案
#1
1
I've managed to successfully receive UILocalNotification on Watch running WatchOS2. Make sure option 'Mirror iPhone Alerts from' is turned on for your app (it's a setting inside Watch(MyWatch) app on iPhone), your iPhone app is not running, iPhone is asleep and locked and the watch is on your wrist.
我成功地在运行WatchOS2的Watch上接收了UILocalNotification。确保为您的应用启用了“Mirror iPhone Alerts from”选项(这是iPhone上Watch(MyWatch)应用程序内的设置),您的iPhone应用程序未运行,iPhone处于睡眠状态且已锁定并且手表已放在手腕上。
#1
1
I've managed to successfully receive UILocalNotification on Watch running WatchOS2. Make sure option 'Mirror iPhone Alerts from' is turned on for your app (it's a setting inside Watch(MyWatch) app on iPhone), your iPhone app is not running, iPhone is asleep and locked and the watch is on your wrist.
我成功地在运行WatchOS2的Watch上接收了UILocalNotification。确保为您的应用启用了“Mirror iPhone Alerts from”选项(这是iPhone上Watch(MyWatch)应用程序内的设置),您的iPhone应用程序未运行,iPhone处于睡眠状态且已锁定并且手表已放在手腕上。