我写这条消息是因为我们在混合时遇到了一个奇怪的问题 动态通知 Controller 和 观看连接来电。
您可以在此处找到我们重现问题的示例项目:https://gitlab.6minutecanoe.com/baptiste.leguelvouit/watch-connectivity-issue
该问题似乎与 didReceiveRemoteNotification
相关。 NotificationController
的方法类(class)。如果我们覆盖这个方法,并且如果我们尝试发送 观看连接 handleActionWithIdentifier
中的消息通过ExtensionDelegate
类,除非我们按 ,否则 Watch 应用程序会卡住数字皇冠按钮 .
这真的很奇怪,因为如果我们不重写这个方法,一切都会正常工作。我们也尝试直接返回WKUserNotificationInterfaceTypeDefault
在这种方法中,但没有任何改变。
有人遇到这个问题吗?
谢谢。
重现步骤:
在真实设备(iPhone + Watch)上启动示例项目,并向其特定设备 token 发送带有自定义类别的远程通知。单击自定义操作按钮时,会出现问题。
版本:
Apple Watch 38mm on watchOS 2.0.1 (13S428) + iPhone 5S on iOS 9.1 (13B143)
配置:
尤其是当我们尝试使用 时会出现问题。动态通知 Controller 返回 WKUserNotificationInterfaceTypeCustom
在其didReceiveRemoteNotification
方法。
最佳答案
看到您的代码后,我的理解是,您要做的是在收到 watch
上的推送通知时....您正在向您的iPhone
发送一条消息用户点击 notification
时的应用程序行动?对吗?而不是在 ExtensionDelegate
中处理操作通知操作类,实现
-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void (^)())completionHandler
您的
AppDelegate
中的方法然后测试它。
关于ios - 无法从动态通知 Controller 发送 Watch Connectivity 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33732712/