javascript - 如果关闭或在后台运行,我应该如何在反应原生 Firebase 应用程序中处理推送通知
问题描述
首先如果应用程序关闭:
this.notificationOpenedListener = firebase.notifications()
.getInitialNotification()
.then((notificationOpen: NotificationOpen) => {
if (notificationOpen) {
// App was opened by a notification
// Get the action triggered by the notification being opened
const action = notificationOpen.action;
// Get information about the notification that was opened
const notification: Notification = notificationOpen.notification;
}
});
第二,如果应用程序在后台运行:
this.notificationOpenedListener = firebase.notifications()
.onNotificationOpened((notificationOpen: NotificationOpen) => {
// Get the action triggered by the notification being opened
const action = notificationOpen.action;
// Get information about the notification that was opened
const notification: Notification = notificationOpen.notification;
});
如何加入代码第一和第二。
参考:这里有链接!
或者如何鞭打应用程序关闭或在后台运行反应原生?
解决方案
推荐阅读
- reactjs - 如果使用另一个可选道具,我可以将 Typescript 必需道具更改为不需要吗?
- python - IndexError:索引 2245 超出轴 0 的范围,大小为 2245
- java - 在querydsl中,FROM子句中的子查询是如何执行的?
- python - 在定义之前引用一个类
- android - 使用伴奏导航动画时如何在 Jetpack Compose 中隐藏底栏
- python - Python 串行读取
- javascript - 使用 JavaScript 的 Google 身份自定义登录
- spring - 如何使用 spring stream sftp 通过 sftp 下载文件?
- docusignapi - 在 DocuSign 中禁止收件人
- python - 有没有办法导入仅在某些 GUI 事件发生时才执行的模块?