ios - 在接收推送通知 IOS 13.2.2 和 watch os 6.1 时向 Apple Watch 延迟通知
问题描述
嗨,我正在开发同时支持 iphone 和 watch 的应用程序。我正在注册来自 iphone 应用程序的用户通知,如下所示。在接收 PUsh 通知时,我可以在 1 到 2 秒内快速收到 iphone 通知。但是对于手表来说,它每次都会延迟 20 秒。我尝试取消配对并重新启动设备,但效果不佳请建议我应该怎么做才能在手表端快速获取通知。我正在使用 iOS 13.2.2 并观看操作系统 - 6.1
{
let approveAction = UIMutableUserNotificationAction()
approveAction.title = NSLocalizedString("Approve", comment: "Notification approve button title")
approveAction.identifier = "approve"
approveAction.isDestructive = false
approveAction.activationMode = .background
approveAction.isAuthenticationRequired = false
let denyAction = UIMutableUserNotificationAction()
denyAction.title = NSLocalizedString("Deny", comment: "Notification deny button title")
denyAction.identifier = "deny"
denyAction.isDestructive = true
denyAction.activationMode = .background
denyAction.isAuthenticationRequired = false
let signInCategory = UIMutableUserNotificationCategory()
signInCategory.setActions([approveAction, denyAction], for: .default)
signInCategory.identifier = "pushotp"
let categories = NSSet(object: signInCategory) as? Set<UIUserNotificationCategory>
let settings = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: categories)
DispatchQueue.main.async(execute: {
UIApplication.shared.registerUserNotificationSettings(settings)
})
}
解决方案
推荐阅读
- reporting-services - 在 SSRS 中导出 excel 时如何添加额外的行和文本
- reactjs - 如何填充 React Formik 表单?
- visual-studio-code - VSCode插入“不间断空格”而不是常规空格
- python - Python - 输出不如预期
- javascript - Angular,Ionic:带有 MAP 的 RxJs Pipe 在 Windows 中不返回值,但在与 httpclient 一起使用时在 mac 中工作
- python - Python 的 psycopg2 可以使用受密码保护的客户端证书和密钥吗?
- c# - 如何从 mvc 中的异步方法重定向到页面
- c++ - 我不知道如何从 cpp 中的一个变量同时返回两个值
- python - 具有未知形状的 Dask 数组
- java - 在 java 类中的 oracle sql 和 java 变量之间进行计算