objective-c - 如何在apple Watch App中模拟Local Notification?

标签 objective-c xcode watchkit

我正在尝试在 Apple Watch 模拟器中模拟本地通知 View 。有谁知道如何在 Apple Watch 中模拟本地通知?

我已经为此做了一些研究,但没有找到上述问题的任何答案。有一种方法可以模拟推送通知,但不能模拟本地通知。

最佳答案

不可能让 Watch 应用程序对模拟器中的 UILocalNotification 使用react。但是,它与对推送通知的 react 几乎相同,只是它通过几种不同的方法进行路由。

如果您要呈现可操作的通知,您的 WKUserNotificationInterfaceController 子类将覆盖 -didReceiveLocalNotification:withCompletion:而不是 -didReceiveRemoteNotification:withCompletion: .

如果您的 Watch 应用启动是为了响应与您的可操作通知之一的交互,那么您的根 WKInterfaceController 将实现 -handleActionWithIdentifier:forLocalNotification:-handleActionWithIdentifier:forRemoteNotification: ,视情况而定。

从 WatchKit 的角度来看,这些是远程通知和本地通知之间的唯一区别。

关于objective-c - 如何在apple Watch App中模拟Local Notification?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27188862/

相关文章:

iphone - NSTimer 和非事件/ sleep 状态

c++ - 链接 Objective-C++

objective-c - 如果我想编写一个 iPad 应用程序,我必须购买 iPad 吗?

c++ - 如何让 LLDB 输出图像?

ios - 在将新界面推送到界面 Controller 上后,如何关闭由界面 Controller 组成的两个页面中不需要的页面?在 Watchkit 上

iphone - 实现为本地存储的视频中的每一帧触发的委托(delegate)

iphone - 了解 self 的使用

ios - Swift3 Collection View 'attempt to delete item 1 from section 1, but there are only 1 sections before the update'

ios - 无法为 Watch Extension 创建专用 App ID

objective-c - WatchKit 接口(interface) : Is it possible to add multiple labels in a tableView group without any of the labels being pushed to the right?