Дублирование уведомлений, когда приложение открыто - PullRequest
0 голосов
/ 01 ноября 2019

Реакция собственного дублирования уведомлений, когда приложение открыто

async componentWillMount() {
    // herhangi bir bildirim etkileşiminde çalışır
    FCM.on(FCMEvent.Notification, notif => {
        console.log("Bildirim geldi", notif);

        if(Platform.OS ==='ios' && notif._notificationType === NotificationType.WillPresent && !notif.local_notification){              
            notif.finish(WillPresentNotificationResult.All)
            return;
        }

    });

    // eğer token yenilenirse çalışır
    FCM.on(FCMEvent.RefreshToken, token => {
        console.log("TOKEN YENİLENDİ (refreshUnsubscribe)", token);
    });

    // Uygulamaya Push atmak için izin alıyoruz
    try {
        let result = await FCM.requestPermissions({badge: false, sound: true, alert: true});
    } catch(e){
        console.error(e);
    }

    // Firebase Cloud Message Token değerini getirir.
    FCM.getFCMToken().then(token => {
        console.log("TOKEN (getFCMToken)", token);
    });

    if(Platform.OS === 'ios') {
        // Eğer APNS istiyorsanız isteğe bağlı APNS TOKEN
        FCM.getAPNSToken().then(token => {
            console.log("APNS TOKEN (getAPNSToken)", token);
        });
    }
}

и моя локальная часть уведомлений

 FCM.scheduleLocalNotification({
                  id: "testnotif2",
                  fire_date:  date_ara1.getTime(),
                  vibrate: 500,
                  title: "Unutmayınız!",
                  body: "Ara Öğünü Saati",
                  sub_text: "sub text",
                  priority: "high",             
                  show_in_foreground: true,
                  wake_screen: true,
                  extra1: { a: 1 },
                  extra2: 1,
                  repeat_interval:'day'
                });

Я прокомментировал эту часть, как https://github.com/evollu/react-native-fcm/issues/442#issuecomment-334154351 этот комментарий, но этоне работает.

if(Platform.OS ==='ios' && notif._notificationType === NotificationType.WillPresent && !notif.local_notification){              
            notif.finish(WillPresentNotificationResult.All)
            return;
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...