Skip to main content

Ionic mParticle Integration for Capacitor

The mParticle plugin provides easy integration with the mParticle SDK in your Capacitor app.

Installation

ionic enterprise register
npm install @ionic-enterprise/capacitor-mparticle-integration
npx cap sync

Configuration

In capacitor.config.json add your keys, secrets, environment, logLevel and bridgeName.

environment is optional, if not provided mParticle will auto detect it. Possible values are "development" and "production".

logLevel is optional. It allows to configure mParticke SDK log level. If not provided, mParticle won't show any logs. Possible values are "debug", "error", "verbose" and "warning".

bridgeName is optional. If set, it has to match the requiredWebviewBridgeName on the mParticle SDK initialization.

"plugins": {
"CapacitorMparticleIntegration": {
"ios-key": "my iOS key",
"ios-secret": "my iOS secret",
"android-key": "my Android key",
"android-secret": "my Android secret",
"environment": "development",
"bridgeName": "mycustombridgename",
"logLevel": "warning"
}
}

In the javascript mParticle initialization code add useNativeSdk: true and requiredWebviewBridgeName with a value that matches bridgeName on the plugin preferences.

window.mParticle = {
config: {
useNativeSdk: true,
requiredWebviewBridgeName: "mycustombridgename"
}
};

Register plugin for Android

In the init method of MainActivity.java add:

add(CapacitorMparticleIntegration.class);

Register plugin for iOS

Plugin is auto-registered on iOS.