如何使用 WatchKit 触发通知 [英] How to trigger notifications using WatchKit
问题描述
在WatchKit 开发者指南中,有说明如何呈现自定义通知,它还说:
In the WatchKit developer guide, there are instructions on how to render custom notifications and it also says:
应用无需执行任何操作即可支持通知.系统提供了一个默认的通知界面,用于显示来自通知的警报消息.但是,应用可以自定义通知界面并包含自定义图形、内容和品牌.
Apps are not required to do anything to support notifications. The system provides a default notification interface that displays the alert message from the notification. However, apps can customize the notification interface and include custom graphics, content, and branding.
我可以获得本地通知以在手机上触发横幅警报,但它们不会在 WatchKit 应用上发生.我已尝试使用所有目标进行调试:
I can get local notifications to trigger banner alerts on the phone, but they don't happen on the WatchKit app. I have tried debugging using all of the targets:
- iOS 应用
- 观看应用
- 观看概览
- 观看自定义通知
即使手机应用程序在后台,当收到本地通知时似乎也没有触发.我还通过模拟在后台接收到的远程通知来尝试此操作.
Even while the phone app is in the background, none seem to trigger when the local notification is received. I have also tried this by simulating a remote notification being received in the background.
我希望我不必直接调用 watchKit 的控制器本地/远程通知处理程序.
I'm hoping I don't have to call the watchKit's controller local/remote notification handlers directly.
推荐答案
我希望我不必直接调用 watchKit 的控制器本地/远程通知处理程序.
I'm hoping I don't have to call the watchKit's controller local/remote notification handlers directly.
不,你没有.
答案是 XCode 目前不支持同时调试 Apple Watch 和 iPhone.这就是为什么您不能将通知从 iPhone 模拟器推送到 Watch 模拟器的原因,目前仅支持通过 *.apns
文件进行的有效负载测试.
The answer is XCode doesn't support debugging Apple Watch and iPhone simultaneously for now. That's why you can't push a notification from iPhone simulator to Watch simulator, only payload test by *.apns
files is supported for now.
这篇关于如何使用 WatchKit 触发通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!