Overview
This page documents the public API of the Mapp Engage Android SDK v7. The entry point is the Appoxee interface, which is available as a singleton once the SDK has been initialized.
For installation and initialization, see Initialize the SDK.
Note
The Android SDK APIs and package names use the Appoxee namespace. This is expected and refers to the Mapp Engage Android SDK.
The Call Pattern
Most SDK methods do not return a value directly. They return a Call<T>, which represents a request that has not been executed yet. Your application decides how and when to run it, which keeps the SDK independent of your threading model.
Execution Methods
Every Call<T> offers three ways to execute the request:
Method | Description | Usage |
|---|---|---|
| Runs the request on the calling thread and returns | Java, from a background thread only |
| Runs the request in the background and delivers | Java and Kotlin, call from the main thread |
| Suspends the coroutine and returns | Kotlin coroutines |
Warning
A
Call<T>can be executed only once.execute()andasSuspend()throw aCallConsumedExceptionon a second attempt.enqueue()does not throw. It delivers aMappResulterror that carries the same exception. To repeat a request, request a newCallfrom the SDK method.
Result Handling
All three execution methods deliver a MappResult<T>:
Member | Returns | Description |
|---|---|---|
|
| Whether the request succeeded |
|
| The result value, or |
|
| The error, or |
Examples
Java
Appoxee.instance().getAlias().enqueue(result -> {
if (result.isSuccess()) {
String alias = result.getData();
} else {
Throwable error = result.getError();
}
});Kotlin
val result = Appoxee.instance().getAlias().asSuspend()
if (result.isSuccess()) {
val alias = result.getData()
} else {
val error = result.getError()
}Note
Method signatures on this page are written in Kotlin. Parameters shown with a default value are optional in Kotlin only. In Java, pass every parameter explicitly.
Initialization
These members are static on Appoxee.
Method | Description | Returns |
|---|---|---|
| Initializes the SDK. Must be called from the main thread, otherwise it throws an |
|
| Returns the SDK singleton. Throws a |
|
| Whether initialization has completed and the SDK is ready to use. This is an instance method. |
|
Device and Identity
Method | Description | Returns |
|---|---|---|
| Returns the registration data of the current device. |
|
| Sets a custom alias for the registered device. When |
|
| Returns the alias of the registered device. |
|
| Logs the user out and resets the alias. |
|
Push Notifications
Method | Description | Returns |
|---|---|---|
| Opts the device in or out of push messages. Pass |
|
| Whether the device is currently opted in. |
|
| Returns the Firebase client token the device is subscribed with. |
|
| Updates the Firebase token of the registered device. The opt-in state stays unchanged. |
|
| Hands a Firebase message to the SDK for processing. Use this when your own service receives push messages instead of |
|
| Whether a Firebase message originates from Mapp. |
|
| Dismisses the notification with the given ID. |
|
| Registers a |
|
In-App Messages and Inbox
Method | Description | Returns |
|---|---|---|
| Fetches in-app messages for the given event and displays them as a dialog or a full-screen page. |
|
| Returns all active inbox messages. |
|
| Returns the inbox message with the given template ID. |
|
| Returns the most recent inbox message. |
|
| Sets the status of an inbox message to |
|
| Displays an inbox message as a banner, dialog, or full-screen page. Native templates use the type configured on the message. Web templates are always shown as a dialog. |
|
Tags
Method | Description | Returns |
|---|---|---|
| Adds a set of tags to the device. |
|
| Removes a set of tags from the device. |
|
| Returns the tags of the device from the local cache. This does not query the backend. |
|
Custom Attributes
Method | Description | Returns |
|---|---|---|
| Adds custom attributes to the device. Takes a |
|
| Takes a set of attribute keys and returns those that exist on the device. |
|
| Clears the given attributes from the local cache and the backend. |
|
Note
removeCustomAttributes()does not delete the attribute keys on the backend. The keys remain and their values are set to an empty string.
Geofencing
Method | Description | Returns |
|---|---|---|
| Starts geofence tracking. With |
|
| Stops geofence tracking. |
|
| Whether geofence tracking is currently active. |
|
Geofencing errors are reported as a GeofenceException, which carries the related GeoStatus.
SDK Status Updates
Register an observer to be notified when the SDK becomes ready. A new subscriber immediately receives the current status.
Method | Description | Returns |
|---|---|---|
| Registers an |
|
| Removes a registered observer. |
|
AppoxeeObserver defines a single method, onReadyStatusChanged(status, result), where result is a MappResult<DevicePayload>.
Warning
Always call
unsubscribe()in the matching lifecycle method to prevent memory leaks.
AppoxeeOptions
AppoxeeOptions is the configuration object passed to Appoxee.engage(). The four constructor parameters are required.
Parameter | Type | Description |
|---|---|---|
|
| The Mapp Engage environment your channel runs on |
|
| SDK key of your Mapp Engage channel |
|
| App ID of your Mapp Engage channel |
|
| Your tenant ID, passed as a string |
Two further properties can be set on the instance before you call engage():
Property | Type | Default | Description |
|---|---|---|---|
|
|
| When the SDK displays push notifications |
|
|
| Whether the SDK writes log output. Available since 7.1.3. |
Server
Use the value that matches your Mapp Engage environment: L3, L3_US, EMC, EMC_US, or CROC.
LogLevel
DEBUG— The SDK logs only when your application is built as debuggable. This is the default.RELEASE— The SDK logs in debuggable and in release builds.
Note
Despite its name,
LogLeveldoes not filter messages by severity. It switches SDK logging on or off as a whole. See Initialize the SDK.
NotificationMode
BACKGROUND_ONLY— Notifications appear only while the app is in the background. This is the default.BACKGROUND_AND_FOREGROUND— Notifications appear in both states.SILENT_ONLY— No notification UI is shown. Push events are still received and processed.
Data Types
DevicePayload
Returned by getDevice() and delivered with SDK status updates.
Property | Type | Description |
|---|---|---|
|
| Unique user ID assigned by Mapp |
|
| Hashed device identifier |
|
| Token used while the device is opted in |
|
| Token retained while the device is opted out |
|
| Alias currently set for the device |
InboxMessage
Property | Type | Description |
|---|---|---|
|
| Template ID of the message |
|
| Message text in increasing level of detail |
|
| URL of the message icon |
|
| Timestamps for delivery and expiry |
|
|
|
|
| Whether the message uses a native template rather than a web template |
|
| Custom key-value pairs sent with the message |
|
| Identifiers of the event that triggered the message |
InboxMessagesResponse wraps a list of these messages together with the eventId of the request.
MappPush
Delivered to the callbacks of a LocalPushBroadcast. It carries id, title, content, actionUri, type, category, language, userId, customerId, a list of actionButtons, the silent-push fields silentType, silentData, and contentAvailable, and any extraFields sent with the message. Each ActionButton has a uri and an action.
LocalPushBroadcast
Extend this class and register it with setPushBroadcast() to react to push lifecycle events. It defines the callbacks onReceived(), onOpened(), onSilent(), onDismissed(), onButtonClick(), and onRichPush(), each receiving a MappPush.