Skip to content

Library events

Alexander Boldyrev edited this page Oct 25, 2024 · 3 revisions

Library events can be subscribed on using the following code snippet:

import 'package:infobip_mobilemessaging/models/library_event.dart';

InfobipMobilemessaging.on(
    LibraryEvent.'<event name>',
    (event) => {
        print('Event received: ' + event.toString());
    });

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.
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>,
    chat: <true/false, indicates is it in-app chat message 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>
}

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