react-native - onNotificationOpened 方法未在反应本机 Firebase 中被调用
问题描述
我在我的 react native 项目中使用 react-native-firebase 进行通知,我试图从 componentDidMount 方法调用 onNotificationOpened 和 getInitialNotification 但这两种方法没有被调用,任何建议将不胜感激
this.removeNotificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen: NotificationOpen) => {
console.log('onNotificationOpened AppJS :', notificationOpen)
const { action, notification } = notificationOpen
let item = JSON.parse(notification.data.body)
console.log('onNotificationOpened AppJS : body ', item)
console.log('onNotificationOpened AppJS : action ', action)
})
firebase.notifications().getInitialNotification()
.then((notificationOpen: NotificationOpen) => {
if (notificationOpen) {
console.log('getInitialNotification AppJS : Shoeb ########: ')
// App was opened by a notification
// Get the action triggered by the notification being opened
const { action, notification } = notificationOpen
let item = JSON.parse(notification.data.body)
console.log('getInitialNotification AppJS : item ', item)
console.log('getInitialNotification AppJS : action ', action)
}
})
解决方案
推荐阅读
- java - 如何修复 Spring Boot 中发生的“HttpMessageNotReadableException”和“SocketTimeOutException”
- angular7 - 根据请求,braintree-web API 中位置 1 处 JSON 中的意外令牌 o
- ruby-on-rails - 如何在 Ruby 中删除 \r\n?
- r - 使用动画包将pdf转换为png
- cucumber - 如何为 Intellij 中耳语的步骤方法设置前缀
- sql - 获取包含多个项目编号的订单号
- java - 如何修复我的 android 应用程序中的布局视图?
- r - 在数据集中为 NA 估算中位数是最好的方法。如果是/否,那为什么?
- umbraco - 无法在 Umbraco LeBlender 网格编辑器中添加 ImageCropper 作为属性
- ios - Xcode 10.2.1:找不到此可执行文件的有效配置文件