Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplication of notification when app is open #1124

Open
OmerGeysoglu opened this issue Nov 1, 2019 · 1 comment
Open

Duplication of notification when app is open #1124

OmerGeysoglu opened this issue Nov 1, 2019 · 1 comment

Comments

@OmerGeysoglu
Copy link

OmerGeysoglu commented Nov 1, 2019

React Native duplication of notification when app is open

async componentDidMount() {
    // 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);
        });
    }
}

and my local notification part

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

i commented this part like #442 (comment) this comment but it's not working.

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

Does anyone have a solution to this ? The notification keeps getting duplicated, i feel it has something to do with the notification listener not being removed. However, when i try to remove the listener , notifications stop coming through even though the listener has already been initialised. Hope i am making sense, please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants