react-native-firebase-收到推送通知后应用崩溃(Android)

时间:2018-09-19 01:29:02

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

我有一个 NodeJS服务器,当我的 React Native应用收到来自服务器的推送通知时,该应用停止运行。

  

仿真器中,该应用程序刚刚关闭,在带有Release APK的手机中,该应用程序已关闭,并显示一条警告,指出该应用程序停止工作。

在这里,我可以显示我在Android应用程序中添加的一些配置

android / build.gradle

classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'

build.gradle

implementation project(':react-native-firebase')
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'

通知侦听器

export const configureMessaging = async () => {
  try {
    const enabled = await FirebaseMessaging.hasPermission();
    log('Push Notifications enabled?', enabled);
    return enabled;
  } catch (err) {
    return false;
  }
}; // This is returning true

export const configureOnNotificationDisplayed = () => FirebaseNotifications.onNotificationDisplayed((notification) => {
  // Process your notification as required
  // ANDROID: Remote notifications do not contain the channel ID.
  // You will have to specify this manually if you'd like to re-display the notification.
  console.log(notification);
});

export const configureOnNotification = () => FirebaseNotifications.onNotification((notification) => {
  // Process your notification as required
  console.log(notification);
});

export const configureOnNotificationOpened = () => FirebaseNotifications.onNotificationOpened((notificationOpen) => {
  // Get the action triggered by the notification being opened
  // Get information about the notification that was opened
  console.log(notification);
});

我在AVM中连接了调试器,没有抛出错误

  

已连接到目标VM,地址:“ localhost:8624”,传输:   'socket'

     

与目标VM断开连接,地址:“ localhost:8624”,   运输:“插座”

注意

  

我不知道iOS中发生了什么,因为未配置该应用   使用iOS

1 个答案:

答案 0 :(得分:0)

问题是我还有另一个依赖关系在使用“推送通知”。我删除了它,一切正常