简体   繁体   English

为什么 Apple Watch 的本地通知会延迟?

[英]Why are Apple Watch's local notifications delayed?

I created an app for Apple Watch with a companion app for iPhone.我为 Apple Watch 创建了一个应用程序,并为 iPhone 提供了一个配套应用程序。 These two apps test the local notifications on both devices.这两个应用程序测试两个设备上的本地通知。

But since I updated to iOS 13.1.2 and WatchOS 6.0.1, the local notifications on Apple are delayed: when I press the button on the watch that creates the notification and I exit the app, it doesn't take 5 seconds to display the notification but about 20 seconds... when I change the code to 3 seconds it takes 16 secs to display.但是由于我更新到 iOS 13.1.2 和 WatchOS 6.0.1,Apple 上的本地通知被延迟:当我按下手表上创建通知的按钮并退出应用程序时,不需要 5 秒即可显示通知,但大约 20 秒......当我将代码更改为 3 秒时,需要 16 秒才能显示。

Is this a new feature on Apple Watch or a bug?这是 Apple Watch 上的新功能还是错误? Because on iPhone it works without any delay.因为在 iPhone 上它可以毫无延迟地工作。

Thank you in advance:)先感谢您:)

    // Configure the notification's payload.
    let content = UNMutableNotificationContent()
    content.title = NSString.localizedUserNotificationString(forKey: "Hello!", arguments: nil)
    content.body = NSString.localizedUserNotificationString(forKey: "Hello_message_body", arguments: nil)
    content.sound = UNNotificationSound.default

    // Deliver the notification in five seconds.
    let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
    let request = UNNotificationRequest(identifier: "FiveSecond", content: content, trigger: trigger) // Schedule the notification.
    let center = UNUserNotificationCenter.current()
    center.add(request) { (error : Error?) in
         if let theError = error {
             // Handle any errors
         }
    }

EDIT:编辑:

I also noticed this strange behavior: when I create a notification on iPhone, pressing the button and then put the phone on stand by so the notification gets delivered to Apple Watch, the notifications gets displayed correctly after 5 seconds on the watch!我还注意到这种奇怪的行为:当我在 iPhone 上创建通知时,按下按钮然后将手机置于待机状态,以便将通知传送到 Apple Watch,通知在手表上 5 秒后正确显示!

I have noticed this also on local notifications generated on the watch.我在手表上生成的本地通知中也注意到了这一点。 I have generated notifications from 30 seconds to 3 minutes (in 30 second increments), and they are consistently about 13 seconds late.我已经生成了从 30 秒到 3 分钟(以 30 秒为增量)的通知,并且它们始终晚了大约 13 秒。 Before watchOS 6, they were not late.在 watchOS 6 之前,他们没有迟到。

I've just updated my Apple Watch to WatchOS 6.1 and yes... they fixed the bug:!!我刚刚将我的 Apple Watch 更新到 WatchOS 6.1,是的……他们修复了这个错误:!! Now the notifications created locally get triggered on time :)现在本地创建的通知会准时触发:)

@JackieNBee have you ran into this issue again post WatchOS 6.1. @JackieNBee 在 WatchOS 6.1 之后您是否再次遇到此问题。 Currently on WatchOS 8.1 and local schedule notifications on watch are delayed for about 13 seconds.目前在 WatchOS 8.1 上,手表上的本地日程通知延迟约 13 秒。 I also have my watch app as a companion app for my iPhone app.我也有我的手表应用程序作为我的 iPhone 应用程序的配套应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM