React Native Bridge API calls (Mapp Cloud)
Implement the plugin
For convenience, you should use Mapp.js and MappEventEmmiter.js.
Initialising SDK
For the Initialization use method, this function should be first in your application :
Mapp.engage(sdkKey: string, googleProjectId: string, server: string, appID: string, tenantID: string);
const App = () => {
...
}
@param {string} sdkID - The SDK ID for your account.
@param {string} googleProjectID - The Google project id from your Firebase console for the chosen app.
googleProjectId - Can be empty String. It is not used, but it is here only for backward compatibility.
@param {string} server - The Server, which will be used for engagement, this info will be provided by account managers.
@param {string} tenantID - The ID which recognizes you at the Mapp Engage system, will be also provided by account managers.
iOS uses most information from AppoxeeCofig.plist as explained in the integration section, so you need to have that plist set up inside iOS project.
Server list:
L3
L3_US
EMC
EMC_US
CROC
Check if the plugin is initialized
const ready = await Mapp.isReady();
Check if the device is registered in Mapp
const registered = await Mapp.isDeviceRegistered();
Alias
Get device alias
Set device alias
Device API
Get device info
Push API
Push Enabled
Check if the feature is enabled.
Push toggle
Disable or enable push.
Request permission to display notification (for Android 13 and higher ONLY)
Push messages event
Push message events are triggered when a push message is received, opened, dismissed, or when a silent push message is received.
Subscribe/listen for push events:
For iOS also is an available listener for rich messages:
Setup for push message handling from React Native plugin
For a use-cases where clients needs to handle push messages on their own, or when using some additional push service (besides MAPP), then some additional setup needs to be done.
Android setup
Multiple firebase services can not exist in the same aplication, it will rise conflicts and unpredictable behaviour. So, we need to disable default service from Mapp native part.
Open android folder and update the AndroidManifest.xml file:
After that we disabled the default Mapp service for receiving and handling push messages, we need to provide another service for push messages. This can be done in 2 ways.
Native implementation
We can create in the native part, our service that will extend MessageService, and implement the required functionality.
Every overridden method must call the super method in order for the underlying plugin works correctly.
React native implementation
For this way of handling push messages, we can use react native plugins:
For complete instructions on how to use the plugins above and install them, please visit the official documentation: Cloud Messaging | React Native Firebase
After we have successfully completed the setup of the app and messaging plugins, we only need to forward Mapp’s push messages to the Mapp plugin:
and also needs to forward Firebase device token
Check if received push message is from MAPP.
@param{RemoteMessage} remoteMessage - message received from firebase messaging service.
Provide firebase token to the Mapp SDK. It’s used for registring device for receiving push messages from Mapp.
@param{String} token - token generated from Firebase Messaging instance.
Pass received firebase message to the Mapp SDK.
@param{RemoteMessage} remoteMessage - message received from firebase messaging service.
Log out
@param{boolean} pushEnabled
- while logging out sets push the state
Handle Deep Links
Mapp plugin provides possibility to handle deep links received in push messages.
Deep-linking is a type of action that can be triggered when the user open the push notification. It provides the ability to open a specific page within the app.
Tags
Retrieving tags:
Adding a tag:
@param{string
} tag - channel tag
Removing tag:
@param{string
} tag - channel tag
Custom Fields API
Set String Field
Set a string value for a key.
@param {string} key - A key to be paired with the value.
@param {string} value - A value which contains string.
Set Numeric Field
Set a number value for a key.
@param {string} key - A key to be paired with the value.
@param {number} value - A value which contains a number, i.e. "34", "34.54".
Set Boolean (Android only)
Set a boolean for a key.
@param {string} key - A key to be paired with the value.
@param {boolean} value - true, false
In-app API
Get Inbox Messages
To get inbox messages use Mapp.fetchInboxMessage()
iOS uses events for inbox messages (Mapp.addInboxMessagesListener
)and cannot return them as promise.
To get the latest inbox message use Mapp.fetchInboxMessage();
Show In-App message
The method triggers an In-App message.
@param {string} event-specific DCM event trigger.
Manage In-app messages
Inapp messages can be marked as read, unread or deleted.
@param{number} templateId
@param{string} eventId
Location API
Start location monitoring
To start Geofencing (Geo targeting) use command Mapp.startGeofencing()
The location manager will be enabled and it will collect the location change events.
On Android, application must request Location permissions in runtime, to be able to start Geofencing.
Mapp plugin provides helper method to request required location permissions: COARSE_LOCATION, FINE_LOCATION, BACKGROUND_LOCATION.
Note that requesting BACKGROUND_LOCATION has strict Google Policy and application must provide valid reasons to do that, otherwise Google can remove application from Google Play. More on this on official Google support pages.
Stop location monitoring
To stop Geofencing use command Mapp.stopGeoFencing()
The location manager will be disabled.