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 :

1 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

1 2 3 Mapp.isDeviceRegistered().then(data => { //do something with data }

 

Alias

Get device alias

1 2 3 4 Mapp.getAlias().then(data => { console.log(data); Alert.alert(data) });

Set device alias

1 Mapp.setAlias(”some alias”)

 

Device API

Get device info

1 2 3 4 Mapp.getDeviceInfo().then(data => { console.log(data); Alert.alert(data) });

 

Push API

Push Enabled

Check if the feature is enabled.

1 2 3 Mapp.isPushEnabled().then(data => { console.log(data); Alert.alert(data.toString())

 

Push toggle

Disable or enable push.

1 Mapp.setPushEnabled(true)

 

Push notification received

Subscribe/listen for push received events:

1 2 3 4 Mapp.addPushListener((notification) => { console.log(JSON.stringify(notification)); Alert.alert(JSON.stringify(notification)) });

For iOS also is an available listener for rich messages:

1 2 3 4 Mapp.addRichMessagesListener((notification) => { console.log(JSON.stringify(notification)); Alert.alert(JSON.stringify(notification)) });

Check if received push message is from MAPP.

@param{RemoteMessage} remoteMessage - message received from firebase messaging service.

1 2 3 Mapp.isPushFromMapp(remoteMessage).then(isMapp =>{ console.log(isMapp); });

 

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.

1 Mapp.setToken(token);

 

Pass received firebase message to the Mapp SDK.

@param{RemoteMessage} remoteMessage - message received from firebase messaging service.

1 Mapp.setRemoteMessage(remoteMessage);

 

Log out

@param{boolean} pushEnabled - while logging out sets push the state

1 Mapp.logOut(pushEnabled)

 

Tags

Retrieving tags:

1 2 3 Mapp.getTags().then(data => { Alert.alert(JSON.stringify(data)) });

 

Adding a tag:

@param{string} tag - channel tag

1 Mapp.addTag("tagName");

 

Removing tag:

@param{string} tag - channel tag

1 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.

1 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".

1 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

1 Mapp.setAttributeBollean("some key", true);

In-app API

Get Inbox Messages

To get inbox messages use Mapp.fetchInboxMessage()

1 2 3 4 5 6 7 8 9 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. 

1 Mapp.triggerInApp("app_open")

 

Manage In-app messages

Inapp messages can be marked as read, unread or deleted.

@param{number} templateId

@param{string} eventId

1 2 3 4 5 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.

1 Mapp.startGeoFencing()

 

Stop location monitoring

The location manager will be disabled.

1 Mapp.stopGeoFencing()