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)
@param {string} sdkID - The SDK ID for your account.
@param {string} googleProjectID - The Google project id from your Firebase console for the chosen app.
@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 device is registered in Mapp
Mapp.isDeviceRegistered().then(data => { //do something with data }
Alias
Get device alias
Mapp.getAlias().then(data => { console.log(data); Alert.alert(data) });
Set device alias
Mapp.setAlias(”some alias”)
Device API
Get device info
Mapp.getDeviceInfo().then(data => { console.log(data); Alert.alert(data) });
Push API
Push Enabled
Check if the feature is enabled.
Mapp.isPushEnabled().then(data => { console.log(data); Alert.alert(data.toString())
Push toggle
Disable or enable push.
Mapp.setPushEnabled(true)
Push notification received
Subscribe/listen for push received events:
Mapp.addPushListener((notification) => { console.log(JSON.stringify(notification)); Alert.alert(JSON.stringify(notification)) });
For iOS also is an available listener for rich messages:
Mapp.addRichMessagesListener((notification) => { console.log(JSON.stringify(notification)); Alert.alert(JSON.stringify(notification)) });
Log out
@param{boolean} pushEnabled
- while logging out sets push the state
Mapp.logOut(pushEnabled)
Tags
Retrieving tags:
Mapp.getTags().then(data => { Alert.alert(JSON.stringify(data)) });
Adding a tag:
@param{string
} tag - channel tag
Mapp.addTag("tagName");
Removing tag:
@param{string
} tag - channel tag
Mapp.removeTag("tagName");
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.
Mapp.setAttributeString("some key", "some value");
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".
Mapp.setAttributeInt("some key", 34);
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
Mapp.setAttributeBollean("some key", true);
In-app API
Get Inbox Messages
To get inbox messages use Mapp.fetchInboxMessage()
Mapp.fetchInboxMessage().then(data => { if (Platform.OS == "ios") { Mapp.addInboxMessagesListener( (messages) => { Alert.alert(JSON.stringify(messages)) }); } else { Alert.alert(JSON.stringify(data)) }
iOS uses events for inbox messages (Mapp.addInboxMessagesListener
)and cannot return them as promise.
Show In-App message
The method triggers an In-App message.
@param {string} event-specific DCM event trigger.
Mapp.triggerInApp("app_open")
Manage In-app messages
Inapp messages can be marked as read, unread or deleted.
@param{number} templateId
@param{string} eventId
Mapp.inAppMarkAsRead(templateId: number, eventId: string); Mapp.inAppMarkAsUnRead(templateId: number, eventId: string); Mapp.inAppMarkAsDeleted(templateId: number, eventId: string);
Location API
Start location monitoring
The location manager will be enabled and it will collect the location change events.
Mapp.startGeoFencing()
Stop location monitoring
The location manager will be disabled.
Mapp.stopGeoFencing()