Спасибо, но у меня это не сработало, в любом случае я изменил способ отправки данных с сервера, теперь в части тела, я отправляю свое сообщение и с тегом, я отправляю свои данные JSON, и теперь уведомление подходит нормально.

ользую библиотеку реактив-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 event
        // sometimes Android kills activity when app goes to background, and when resume it broadcasts notification before JS is run. You can use FCM.getInitialNotification() to capture those missed events.
        // initial notification will be triggered all the time even when open app by icon so send some action identifier when you send notification
        /*FCM.getInitialNotification().then(notif => {
            console.log('FCM', notif)
            this.sendRemote(notif)
            //console.log('Initial Notification',notif)
        });*/

        FCM.getInitialNotification().then((notif: any) => {
            // for android/ios app killed state
            console.log("ifAny",notif)
            if (notif) {
                console.log("Any",notif)
                // there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
            }
        });
    }




sendRemote(notif) {
    var data = notif.fcm.body;
    var title = notif.fcm.title;
    FCM.presentLocalNotification({
        title: 'App Name',
        body: title,
        big_text: title,
        large_icon: 'ic_launcher',
        priority: 'high',
        sound: "default",
        click_action: this.clickActions(notif),
        show_in_foreground: true,
        wake_screen: true,
        local: true,
        param: notif.notify_about,
        paramData: data
    });
}

notify_about: '', fcm: {action: null, body: "{data: '', time: ''}", цвет: null, icon: '', tag: null, title: "Заголовок уведомления"}

это мой формат данных, который я отправляю с сервера.

Здесь я хочу показать только данные тела. Но когда приложение убито или находится в фоновом режиме, оно показывает полное тело в уведомлении. И оно работает нормально, когда приложение работает.

Ответы на вопрос(0)

Ваш ответ на вопрос