The notification API used to configure and display device notifications to users on their devices across different platforms. The notifications must be explicitly granted by users on an origin basis and only are triggered by the code executing in a secure context.
The app.notification.onReceived
event is called when a notification (FCM, APNS) has been received.
Type:
Function
app.notification.onReceived = function (data) {};
app.notification.onReceived
has one entry argument which is named data.
Parameters | Type | Description |
---|---|---|
data | Object | The object contain of notification detail, like type, key, and details of notification. |
// on notification received event
app.notification.onReceived = function (data) {
if (data.key) {
var openedAt = app.now();
ref.child('nmis/' + data.key + '/openedAt').set(openedAt, function (error) {
if (error)
console.error('set opened at failed', error);
});
}
// show the relative page
if (data.type === 'client')
clientPage.show(data.details.notification.value.data);
};