Cordova Push Notification using FCM not working when the app is closed

266 Views Asked by At

When the app is in foreground/background, everything is fine I can receive the notification, its data and the navigation works. When the app is totally closed, I receive the notification but when I tap it I am being redirected to the main page, the data.wasTapped is not being triggered. It's like the app opens up with initial mode and I want it to go the data.confirm_page I send. The noNotification is not working when the app is closed, any suggestions?

FCM:

FCM.onNotification(data => {
    if (data.wasTapped) {
        // should redirect to data.confirm_page
    },
    else {
        // displaying a pop message, when the user confirms it sends him/her to the specified route
    }
}

Push API:

{
    "to": "fcm token",
    "notification": {
        "title": "this is the title",
        "body": "this is the body",
        "click_action": "FCM_PLUGIN_ACTIVITY",
        "icon": "notification_icon",
        "iconColor": "#e73439"
    },
    "android": {
        "priority": "0"
    },
    "time_to_live_sec": 86400,
    "data": {
        "confirm_page": "/help",
        "confirm_label": "OK",
        "callback_data": {},
        "reject_label": "Cancel"
    }
}
0

There are 0 best solutions below