gpt4 book ai didi

ios - 当应用程序被用户杀死时,WhatsApp 如何处理 iOS 上的静默推送通知?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:28:36 25 4
gpt4 key购买 nike

据我了解,当用户通过多任务 UI 终止应用程序时,静默推送通知不会调用 application:didReceiveRemoteNotification:fetchCompletionHandler:。但是在查看 WhatsApp 的行为时,我不明白他们是如何做到以下几点的:

  • 将 channel 静音
  • 强制退出 WhatsApp
  • 在静音 channel 接收消息
  • 显示角标(Badge)
  • 更令人惊讶的是 =>
  • 不启动 WhatsApp,启动飞行模式
  • 现在启动 WhatsApp => 文本显示在正确的位置

这意味着 WhatsApp 以某种方式管理它来处理推送通知的接收,尽管该应用程序已被终止。有谁知道如何?使用 .badge, .alert, ...?

最佳答案

还有其他方法可以更新您的应用程序。另一种方法是使用 background app refresh .后台应用刷新让您的应用在后台定期运行,以便更新其内容。

--编辑添加其他可能的方法:--

另一种可以在应用程序被杀死后短时间(固定长度时间)使用的方法是请求 background execution time。 .这可以为应用提供更多运行时间。

对于需要更多执行时间才能执行的任务,您必须请求特定权限才能在后台运行它们而不会被挂起。在 iOS 中,only specific app types are allowed to run in the background .例如,支持互联网协议(protocol)语音 (VoIP) 的应用程序或充当蓝牙 LE 配件的应用程序。

--编辑#2--

从 WhatsApp 应用程序的 info.plist 来看,它使用了多种 UIBackgroundModes,其中任何一种都可以用来唤醒/保持应用程序在后台。

WhatsApp 的 info.plist 部分:

<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
<string>remote-notification</string>
<string>voip</string>
</array>

关于ios - 当应用程序被用户杀死时,WhatsApp 如何处理 iOS 上的静默推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52481815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com