相关疑难解决方法(0)

在应用程序被杀或在react-native-fcm中的后台显示以JSON格式显示的fcm通知消息

我正在使用react-native-fcm库为Android设备.当我的应用程序运行时,我正在收到正确的通知,但是当我的应用程序在后台或被杀时,我收到的JSON格式的通知数据类似于我在这里分享的图像.

在此输入图像描述

componentDidMount() {
        // iOS: show permission prompt for the first call. later just check permission in user settings
        // Android: check permission in user settings
        FCM.requestPermissions().then(()=>console.log('granted')).catch(()=>console.log('notification permission rejected'));
        /*FCM.getFCMToken().then(token => {
            console.log('Token',token)
            // store fcm token in your server
        });*/
        this.notificationListener = FCM.on(FCMEvent.Notification, async(notif) => {
            console.log('FCM notification', notif)
            this.sendRemote(notif)
        });

        // initial notification contains the notification that launchs the app. If user launchs app by clicking banner, the banner notification info will be here rather than through FCM.on …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-fcm

5
推荐指数
0
解决办法
751
查看次数