Skip to content

Library events

Alexander Boldyrev edited this page Nov 8, 2022 · 1 revision

Events can be subscribed on using the following code snippet:

MobileMessaging.register('<event name>',
     function(eventData) {
         console.log('Event: ' + eventData);
     }
);

where <event name> is the name of event listed in the table.

Event name Event data Description
messageReceived message object Occurs when new message arrives, see separate section for all available message fields
notificationTapped message object Occurs when notification is tapped.
tokenReceived Cloud token Occurs when an APNs device token is received. Contains device token - a hex-encoded string received from APNS. Returns device token as hex-encoded string.
registrationUpdated Infobip internal ID Occurs when the registration is updated on backend server. Returns internalId - string for the registered user.
geofenceEntered geo object Occurs when device enters a geofence area.
actionTapped message, actionId, text Occurs when user taps on action inside notification or enters text as part of the notification response.
installationUpdated installation Occurs when save request to the server is successfully sent.
userUpdated user Occurs when save request to the server is successfully sent.
personalized Occurs when request for personalization is successfully sent to the server.
depersonalized Occurs when request for depersonalization is successfully sent to the server.

Supported message object fields are described below:

message: {
    messageId: <unique message id>,
    title: <title>,
    body: <message text>,
    sound: <notification sound>,
    vibrate: <true/false, notification vibration setting (Android only)>,
    icon: <notification icon, optional (Android only)>,
    silent: <true/false, disables notification for message>,
    category: <notification category (Android only)>,
    receivedTimestamp: <absolute timestamp in milliseconds that indicates when the message was received>,
    customPayload: <any custom data provided with message>,
    originalPayload: <original payload of message (iOS only)>,
    contentUrl: <media content url if media provided>,
    seen: <true/false, was message seen or not>,
    seenDate: <absolute timestamp in milliseconds that indicates when the message was seen>,
    geo: <true/false, indicates was message triggered by geo event or not>,
    chat: <true/false, indicates was message triggered by chat or not>,
    browserUrl: <string, url to open in browser>,
    deeplink: <string, deeplink url>,
    webViewUrl: <string, url to display in webview>,
    inAppOpenTitle: <string, custom title for in-app open button>,
    inAppDismissTitle: <string, custom title for in-app dismiss button>
}

Supported geo object fields are described below:

geo: 
    area: {
        id: <area id>,
        center: 
            lat: <area latitude>,
            lon: <area longitude>
        },
        radius: <area radius>,
        title: <area title>
    }
}

In this wiki you can also find support for users and installations objects

Clone this wiki locally