/MC-Cordova-Plugin

Primary LanguageObjective-CBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Salesforce Marketing Cloud Cordova Plugin

Use this plugin to implement the Marketing Cloud MobilePush SDK for your iOS and Android applications.

Release Notes

Release notes for the plugin can be found here

Installation

1. Add plugin to your application via npm

cordova plugin add cordova-plugin-marketingcloudsdk

2. Provide Marketing Cloud credentials

  1. Add MarketingCloudSDKConfiguration.json to your application.
[
  {
    "name": "production",
    "appid": "<your app id>",
    "accesstoken": "<your access token>",
    "marketing_cloud_server_url": "<your tenant-specific url>",
    "mid": "<your app mid>",
    "etanalytics": true,
    "pianalytics": true,
    "location": true,
    "inbox": true,
    "uselegacypiidentifier": true
  }
]
  1. Add the following to your application's config.xml file.
<platform name="ios">
  <resource-file src="MarketingCloudSDKConfiguration.json" />
</platform>

3. Provide FCM credentials

To enable push support for the Android platform you will need to include the google-services.json file.

  1. Download the file from your application's Firebase console and place it in your project's root folder.
  2. Add following to Android element in your config.xml:
<platform name="android">
  <resource-file src="google-services.json" target="app/google-services.json" />
</platform>

API Reference


MCCordovaPlugin

MCCordovaPlugin.isPushEnabled(successCallback, [errorCallback])

The current state of the pushEnabled flag in the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin See

Param Type Description
successCallback function
successCallback.enabled boolean Whether push is enabled.
[errorCallback] function

MCCordovaPlugin.enablePush([successCallback], [errorCallback])

Enables push messaging in the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin See

Param Type
[successCallback] function
[errorCallback] function

MCCordovaPlugin.disablePush([successCallback], [errorCallback])

Disables push messaging in the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin See

Param Type
[successCallback] function
[errorCallback] function

MCCordovaPlugin.getSystemToken(successCallback, [errorCallback])

Returns the token used by the Marketing Cloud to send push messages to the device.

Kind: static method of MCCordovaPlugin See

Param Type Description
successCallback function
successCallback.token string The token used for push messaging.
[errorCallback] function

MCCordovaPlugin.getAttributes(successCallback, [errorCallback])

Returns the maps of attributes set in the registration.

Kind: static method of MCCordovaPlugin See

Param Type Description
successCallback function
successCallback.attributes Object.<string, string> The key/value map of attributes set in the registration.
[errorCallback] function

MCCordovaPlugin.setAttribute(key, value, [successCallback], [errorCallback])

Sets the value of an attribute in the registration.

Kind: static method of MCCordovaPlugin See

Param Type Description
key string The name of the attribute to be set in the registration.
value string The value of the key attribute to be set in the registration.
[successCallback] function
successCallback.saved boolean Whether the attribute value was set in the registration.
[errorCallback] function

MCCordovaPlugin.clearAttribute(key, [successCallback], [errorCallback])

Clears the value of an attribute in the registration.

Kind: static method of MCCordovaPlugin See

Param Type Description
key string The name of the attribute whose value should be cleared from the registration.
[successCallback] function
successCallback.saved boolean Whether the value of the key attribute was cleared from the registration.
[errorCallback] function

MCCordovaPlugin.addTag(tag, [successCallback], [errorCallback])

Kind: static method of MCCordovaPlugin See

Param Type Description
tag string The tag to be added to the list of tags in the registration.
[successCallback] function
successCallback.saved boolean Whether the value passed in for tag was saved in the registration.
[errorCallback] function

MCCordovaPlugin.removeTag(tag, [successCallback], [errorCallback])

Kind: static method of MCCordovaPlugin See

Param Type Description
tag string The tag to be removed from the list of tags in the registration.
[successCallback] function
successCallback.saved boolean Whether the value passed in for tag was cleared from the registration.
[errorCallback] function

MCCordovaPlugin.getTags(successCallback, [errorCallback])

Returns the tags currently set on the device.

Kind: static method of MCCordovaPlugin See

Param Type Description
successCallback function
successCallback.tags Array.<string> The array of tags currently set in the native SDK.
[errorCallback] function

MCCordovaPlugin.setContactKey(contactKey, [successCallback], [errorCallback])

Sets the contact key for the device's user.

Kind: static method of MCCordovaPlugin See

Param Type Description
contactKey string The value to be set as the contact key of the device's user.
[successCallback] function
successCallback.saved boolean Whether the value passed in for contactKey was saved in the registration.
[errorCallback] function

MCCordovaPlugin.getContactKey(successCallback, [errorCallback])

Returns the contact key currently set on the device.

Kind: static method of MCCordovaPlugin See

Param Type Description
successCallback function
successCallback.contactKey string The current contact key.
[errorCallback] function

MCCordovaPlugin.enableVerboseLogging([successCallback], [errorCallback])

Enables verbose logging within the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin See

Param Type
[successCallback] function
[errorCallback] function

MCCordovaPlugin.disableVerboseLogging([successCallback], [errorCallback])

Disables verbose logging within the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin See

Param Type
[successCallback] function
[errorCallback] function

MCCordovaPlugin.setOnNotificationOpenedListener(notificationOpenedListener)

Kind: static method of MCCordovaPlugin Since: 6.1.0

Param Type
notificationOpenedListener function
notificationOpenedListener.event MCCordovaPlugin~notificationOpenedCallback

MCCordovaPlugin~notificationOpenedCallback : function

Kind: inner typedef of MCCordovaPlugin

Param Type Description
timeStamp number Time since epoch when the push message was opened.
values Object The values of the notification message.
values.alert string The alert text of the notification message.
[values.title] string The title text of the notification message.
[values.url] string The url associated with the notification message. This can be either a cloud-page url or an open-direct url.
values.type string Indicates the type of notification message. Possible values: 'cloudPage', 'openDirect' or 'other'