Swift中未收到设备的无声推动通知

发布于 2025-02-01 13:28:42 字数 372 浏览 2 评论 0原文

当我发送通知时。我在设备上随机收到通知。 我正在向5个设备发送通知。现在,有3个设备收到通知,而2个设备未收到。

  • 当该应用在前景中运行时,我将在所有设备中收到通知。
  • 当应用在后台时,我会收到通知。
  • 当应用程序被用户杀死,甚至电话被锁定时,我没有在几个设备中收到任何通知,也没有在其他设备中收到。

现在,当我打开应用程序时,我立即收到通知。 我阅读了Apple Doc的一篇文章有​​关无声推动通知的文章,并清楚地提到没有保证向设备传递通知。

我无法使用正常通知,因为在向用户显示的通知之前,我正在过滤数据。如果有效载荷具有等于存储的设备ID的设备ID,则我发出了本地通知,如果没有,则通知是无声的。 这个问题有任何解决方案吗?

When I send the notification. I am getting the notification randomly on the devices.
I was sending notification to 5 devices. Now 3 devices were receiving the notification and 2 device didn't received.

  • When the app is running in the foreground I am getting notification in all devices.
  • When app is in background I am getting notifications.
  • When app is killed by the user and even phone is locked I didn't receive any notification in couple of devices and received in other device.

Now, when I open the app I immediately received the notification.
I read an article from apple doc on silent push notification and there it is clearly mentioned that there is no guarantee of notification delivery to the device.

I cannot use normal notifications because I am filtering data before the notification shown to user. If payload have device id which is equal to stored device id then I fired a local notification if not then notification is silent.
Any solution for this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

涫野音 2025-02-08 13:28:43

您可以使用UnnotificationServiceExtension,该文章允许在交付给用户之前修改远程通知内容。 Here is the reference link : https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension< /a>

You can use UNNotificationServiceExtension which allows modification of a remote notification content before its delivered to the user. Here is the reference link : https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文