react-native-firebase 无法处理通知 click_action 以导航到通知屏幕 [英] react-native-firebase unable to handle notification click_action to navigate to notification screen

查看:74
本文介绍了react-native-firebase 无法处理通知 click_action 以导航到通知屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个 react-native-firebase 和 react-navigation 进行导航,无论是在前台还是后台,我都可以成功地从服务器或控制台推送通知,但我发誓文档不太清楚如何打开通知和导航到它所属的通知屏幕.这些是我的 onMessage 代码.

i'm using this react-native-firebase and react-navigation for navigating and i can push notification from server or console successfully whether its in foreground or background but i swear the documentation is not pretty clear how to open notification and navigate to the notification screen it belongs to. these are my onMessage codes.

 firebase.messaging().onMessage((payload) => {

     if(!payload.opened_from_tray){
      firebase.messaging().createLocalNotification({
        title: payload.title,
        body: payload.body,
        show_in_foreground: true,
        icon: "ic_launcher",
        local_notification: "true",
        priority: "high",
        click_action:"ACTION",
        opened_from_tray: true,
      })
     }


  });

我正在运行 react-native-firebase 3.2.2 版

i'm running the version 3.2.2 of react-native-firebase

推荐答案

现在我没有使用 createLocalNotification(),所以我可以在使用 getInitialNotification() 关闭我的应用程序时收到通知,:)

right now i am not using createLocalNotification(), so am able to receive a notification when my app is closed using getInitialNotification(), :)

firebase.messaging().getInitialNotification()
    .then(payload => {
      console.log(payload);
      if(payload.slug != undefined){
        this.props.navigation.navigate('notification',{slug:payload.slug});
      }else{

      }
    });

我希望它也能解决您的问题

i hope it solves your issue too

这篇关于react-native-firebase 无法处理通知 click_action 以导航到通知屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆