android - onNotificationOpened 适用于 Android 模拟器,但不适用于实际设备
问题描述
我在我的 react-native 应用程序中使用 firebase 通知模块。它在模拟器中完美运行,但是当我在移动设备中安装应用程序时,打开通知时永远不会调用 onNotificationOpened 事件侦听器。我错过了什么?
环境
- 开发操作系统:Windows
构建工具:
- React Native 版本:0.60.5
- React Native Firebase 版本:5.5.6
- Firebase 模块:通知
代码片段:
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
Linking.openURL('https://www.google.com/');
});
/*
* If your app is closed, you can check if it was opened by a notification being clicked / tapped / opened as follows:
* */
const notificationOpen = await firebase.notifications().getInitialNotification();
if (notificationOpen) {
Linking.openURL('https://www.google.com/');
}
解决方案
推荐阅读
- c# - 如何使用 MVC 控制器中的操作内的重定向退后两步浏览器历史记录?
- yii2 - Yii2 Select2 也跨越了原始选择
- erlang - 我怎样才能摆脱 Elixir 中的 Enum.reduce
- java - Spring Cloud - Feign - 无法实例化 [feign.Retryer]
- sql - 在一次点击数据库中选择所有多对多记录以及父表
- c# - CacheManager 与 inproc 和 Redis 一起处理,因为背板未同步
- javascript - Javascript 删除“字符串”中的空格
- debugging - 在本地目录中找不到 .gdbinit 文件
- postgresql - 从历史数据中查询当前数据
- python - pandas groupby 多级标题