Introduction
The plugin provides methods to identify devices, store custom attributes, manage tags, track events, and handle logout. Most methods are available on both platforms unless noted.
Device Alias
An alias links the device to a known user identity in Mapp Engage.
// Set alias
Mapp.setAlias('user@example.com');
// Set alias and resend previously stored custom attributes to the backend
Mapp.setAlias('user@example.com', true);
// Get current alias
const alias = await Mapp.getAlias();Custom Attributes
Set
// Set multiple attributes at once
Mapp.setAttributes({ plan: 'premium', region: 'EU' });
// Set a single string attribute
Mapp.setAttributeString('plan', 'premium');
// Set a single integer attribute
Mapp.setAttributeInt('login_count', 5);Get
const values = await Mapp.getAttributes(['plan', 'region']);
const plan = await Mapp.getAttributeStringValue('plan');Remove (Android only)
Mapp.removeAttribute('plan');Increment Numeric Attribute (iOS only)
Mapp.incrementNumericKey('purchase_count', 1);Tags
Mapp.addTag('premium');
Mapp.removeTag('trial');
const tags = await Mapp.getTags();Custom Events
Use the CustomEvent class to build and send tracking events to the Mapp backend.
import CustomEvent from 'react-native-mapp-plugin/CustomEvent';
import { Mapp } from 'react-native-mapp-plugin';
const event = new CustomEvent('purchase', 49.99);
event.transactionId = 'order-12345';
event.addProperty('currency', 'USD');
event.addProperty('category', 'subscription');
await Mapp.addCustomEvent(event);CustomEvent constructor and properties:
name(string, required): Event name used for identification in Mapp Engage.value(number, optional): Numeric value associated with the event.transactionId(string): Prevents duplicate events on the backend.addProperty(name, value): Attaches metadata. Value may be string, number, boolean, or string[].
Log Out
Clears the user identity from the device. Pass true to keep push notifications active after logout.
Mapp.logOut(true);