簡體   English   中英

在react-native-fcm上處理錯誤

[英]Error handling on react-native-fcm

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

console.error: "Notification handler err", {"line":67974,"column":14,"sourceURL":"http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false"}

環境:react-native-cli:2.0.1

反應原生:0.40.0

react-native-fcm:6.1.0

我在Android ver 6.0.1上測試,應用程序正在前台運行。

我在index.js上刪除了舊代碼Firebase初始化代碼,導致錯誤。

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

我刪除它,它現在正在工作。

對於反應原生的fcm。 請參閱對象aps.alert 在此輸入圖像描述

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
}) 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM