javascript - Expo 推送通知检测

标签 javascript react-native push-notification notifications expo

我如何检测即将到来的通知并在应用程序关闭时进行一些更改...

我正在使用expo-notifications https://docs.expo.io/versions/latest/sdk/notifications/

最佳答案

您的应用在关闭/后台运行时不会收到通知,直到用户与其交互。

来自Expo 38 release notes :

If the notification is triggered while the app is in background,

  • it’s presented immediately

  • the application is not informed of this

If the notification is triggered while the app is in foreground,

  • the application not only receives immediate information about this, but…

  • it can also decide at runtime whether to display a heads-up alert or play a sound! (For more information see the Notification Handler documentation.)

来自Notifications overview ,有 2 个监听器:

addNotificationReceivedListener - This listener is fired whenever a notification is received while the app is foregrounded

addNotificationResponseReceivedListener - This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)

Notifications SDK也是一个很好的引用。

关于javascript - Expo 推送通知检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63820364/

相关文章:

javascript - 如何使用javascript长轮询多个url?

javascript - 带有 Typescript 的 ES6 箭头函数

ios - 如何不让用户通过单击通知打开应用程序?

ios - iOS分发推送通知是否需要设备 token

javascript - Safari 推送通知 + 权限 "denied"且未找到日志

javascript - 停留在这个 jquery 插件的结构上

javascript - vue.js v-bind :value is not working with select option form element

javascript - 在 react 中使用 axios 拦截器的问题

javascript - 在 native react 中更新/更改状态对象的最佳方法?

security - React Native + JWT 还需要刷新 token 吗?