react-native-firebase无法处理通知click_action导航到通知屏幕

时间:2018-01-18 10:43:42

标签: android react-native react-navigation react-native-firebase react-native-fcm

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

 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

1 个答案:

答案 0 :(得分:2)

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

export class AlertComponent implements OnInit {

  public alert: string = `
  <div class="alert [type]">
    <span>[title]</span>
    <p>[message]</p>
  </div>`;

  constructor(private alertService: AlertService) { }

  ngOnInit() {
    this.alertService.getInstance().subscribe(val => {
      console.log(val);
    });
  }

  success() {
    this.alertService.push('error', 'ninja', 'hahahahahahah hahhahaha hahah hah');
  }

}

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