gpt4 book ai didi

android - 在后台和前台使用 Expo 更改推送通知中的角标(Badge)计数

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

我正在研究将推送通知发送到 native 应用程序并阅读 expo 文档的方法,我被两条似乎相互矛盾的信息弄糊涂了。

Notifications will appear in the system notification tray as you've come to expect, and tapping them will open/foreground the app.

(来源:https://docs.expo.io/versions/latest/guides/push-notifications)

但是在“为什么不展览”一节中指出:

Expo apps don't support background code execution (running code when the app is not foregrounded or the device is sleeping). This means you cannot use background geolocation, play audio in the background, handle push notifications in the background, and more.

(来源:https://docs.expo.io/versions/latest/introduction/why-not-expo)

这似乎自相矛盾,因为“前景化”或“打开”应用程序意味着它在我看来是在后台运行。

最后我想用这个更改应用程序图标的通知角标(Badge),但鉴于此信息,我不清楚这是否可能?在 IOS 和 Android 中?

最佳答案

确实前台应用程序听起来好像应用程序在后台主动运行,因此可以运行代码,但正如文档所述,这目前不可行单独的世博会。这意味着无法在应用程序处于后台时更改角标(Badge)计数。

另一方面,当应用程序在前台或通知正在打开时,根据 this table in the documentation 这变得可行。 .

在 iOS 上设置任意角标(Badge)计数可以用 Notifications.setBadgeNumberAsync(number) 完成,而对于 Android the only option available是使发送的推送通知计入给定 channel 的角标(Badge)计数。

关于android - 在后台和前台使用 Expo 更改推送通知中的角标(Badge)计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52567251/

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