![](/img/trans.png)
[英]iOS WatchKit - how to determine if your code is running in watch extension or the app
[英]Determine if UNNotificationResponse is from watch extension or iOS app
当使用func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
在UNUserNotificationCenterDelegate
处理位置通知时, UNUserNotificationCenterDelegate
可以确定用户是否使用手表应用程序或在 iOS 设备上?
默认情况下,如果带有配套 WatchKit 应用程序的 iOS 应用程序收到通知,系统将首先决定是在 iPhone 还是 Apple Watch 上显示警报。 如果通知发送到 Apple Watch,将首先显示“短视”通知场景。 这包括应用程序图标、通知标题和 WatchKit 应用程序的名称
看看这个教程
您还必须为 iPhone 和 Watchkit 实施 UNUserNotificationCenterDelegate 并采取相应措施。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.