在react-native-fcm上处理错误

时间:2017-03-08 20:10:45

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

我正在使用https://github.com/evollu/react-native-fcm在我的react-native应用程序上集成FCM。 通知有效,但我每次都收到此错误。

DateRange | Occurrence-Count-1to2-Times | Occurrence-Count-3to5-Times | Occurrence-Count-6to10-Times | Occurrence-Count-Over10-Times

环境: react-native-cli:2.0.1

react-native:0.40.0

react-native-fcm:6.1.0

我在Android ver 6.0.1上进行测试,应用程序正在前台运行。

2 个答案:

答案 0 :(得分:3)

我在index.js上删除了旧代码Firebase初始化代码,导致错误。

firebase.initializeApp({
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    storageBucket: ""
});

我删除了它,它现在正在工作。

答案 1 :(得分:0)

对于本机反应fcm。查看对象 aps.alert enter image description here

FCM.on("FCMNotificationReceived", (notification) => {
      if (Platform.OS === 'ios') {
        if (notification && notification.aps) {
          const localNotification = {
            title: notification.aps.alert.title,
            body: notification.aps.alert.body,
            show_in_foreground: true,
          }
          FCM.presentLocalNotification(localNotification);
        }
      }
    });


FCM.on("FCMNotificationReceived", (notification) => {
// Also trigged when FCM.presentLocalNotification() and callback a notification without **aps** object;
// So the app crash, error
// Just check if (notification && notification.aps) and make localNotification object like above code
})