如何在Apple Watch App中模拟本地通知? [英] How to simulate the Local Notification in apple Watch App?
问题描述
我正在尝试在Apple Watch Simulator中模拟本地通知视图.有没有人知道如何在Apple Watch中模拟本地通知?
I am trying to simulate the local notification view in apple watch simulator. Does any one known how to simulate the local notifications in apple watch ?
我为此做了一些研究,但没有找到以上答案.有一种方法可以模拟PUSH NOTIFICATION,但不能模拟LOCAL NOTIFICATION.
I have done some research for that but didn't found any answer for the above. There is a way to simulate the PUSH NOTIFICATION but not for the LOCAL NOTIFICATION.
推荐答案
在模拟器中,Watch应用程序无法对UILocalNotification
做出反应.但是,除了通过几种不同的方法进行路由之外,它与对推送通知做出反应几乎相同.
It is not possible to have a Watch app react to a UILocalNotification
in the simulator. However, it is almost identical to reacting to a push notification, except it gets routed through a couple of different methods.
如果您要提交可操作的通知,则您的WKUserNotificationInterfaceController
子类将覆盖 -didReceiveRemoteNotification:withCompletion:
.
If you're presenting an actionable notification, your WKUserNotificationInterfaceController
subclass would override -didReceiveLocalNotification:withCompletion:
instead of -didReceiveRemoteNotification:withCompletion:
.
如果您的Watch应用是为了响应与您的一项可行通知的交互而启动的,则您的根WKInterfaceController
将实现 -handleActionWithIdentifier:forRemoteNotification:
(视情况而定).
If your Watch app is getting launched in response to interacting with one of your actionable notifications, then your root WKInterfaceController
would implement -handleActionWithIdentifier:forLocalNotification:
or -handleActionWithIdentifier:forRemoteNotification:
, as appropriate.
从WatchKit的角度来看,这些是远程通知和本地通知之间的唯一区别.
From WatchKit's point-of-view, those are the only distinctions between remote and local notifications.
这篇关于如何在Apple Watch App中模拟本地通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!