Use this plugin to implement the Marketing Cloud MobilePush SDK for your iOS and Android applications.
Release notes for the plugin can be found here
1. Add plugin to your application via npm
cordova plugin add cordova-plugin-marketingcloudsdk
Required for iOS
You must have Cocoapods installed for the iOS platform integration. Execute the following commands from terminal to install:
sudo gem install cocoapods
pod repo update
<!-- Required -->
<preference name="com.salesforce.marketingcloud.app_id" value="{Marketing Cloud application id}" />
<preference name="com.salesforce.marketingcloud.access_token" value="{Marketing Cloud access token}" />
<preference name="com.salesforce.marketingcloud.tenant_specific_endpoint" value="{URL retrieved from Marketing Cloud adminstration page}" />
<!-- Required - Android Only -->
<platform name="android">
<preference name="com.salesforce.marketingcloud.notification_small_icon" value="ic_notification" />
</platform>
<!-- Optional -->
<preference name="com.salesforce.marketingcloud.analytics" value="{true|false}" />
<preference name="com.salesforce.marketingcloud.delay_registration_until_contact_key_is_set" value="{true|false}" />
To enable push support for the Android platform you will need to include the google-services.json file.
- Download the file from your application's Firebase console and place it in your project's root folder.
- Add following to Android element in your
config.xml
:
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
Follow these instructions to enable rich notifications for iOS.
- MCCordovaPlugin
- static
- .isPushEnabled(successCallback, [errorCallback])
- .enablePush([successCallback], [errorCallback])
- .disablePush([successCallback], [errorCallback])
- .getSystemToken(successCallback, [errorCallback])
- .getDeviceId(successCallback, [errorCallback])
- .getAttributes(successCallback, [errorCallback])
- .setAttribute(key, value, [successCallback], [errorCallback])
- .clearAttribute(key, [successCallback], [errorCallback])
- .addTag(tag, [successCallback], [errorCallback])
- .removeTag(tag, [successCallback], [errorCallback])
- .getTags(successCallback, [errorCallback])
- .setContactKey(contactKey, [successCallback], [errorCallback])
- .getContactKey(successCallback, [errorCallback])
- .enableLogging([successCallback], [errorCallback])
- .disableLogging([successCallback], [errorCallback])
- .setOnNotificationOpenedListener(notificationOpenedListener)
- .setOnUrlActionListener(urlActionListener)
- .logSdkState([successCallback], [errorCallback])
- .track(event)
- .setAnalyticsEnabled(enabled, [successCallback], [errorCallback])
- .isAnalyticsEnabled(successCallback, [errorCallback])
- .setPiAnalyticsEnabled(enabled, [successCallback], [errorCallback])
- .isPiAnalyticsEnabled(successCallback, [errorCallback])
- inner
- ~notificationOpenedCallback :
function
- ~urlActionCallback :
function
- ~notificationOpenedCallback :
- static
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 |
Enables push messaging in the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
See
Param | Type |
---|---|
[successCallback] | function |
[errorCallback] | function |
Disables push messaging in the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
See
Param | Type |
---|---|
[successCallback] | function |
[errorCallback] | function |
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 |
Returns the deviceId used by the Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
See
Param | Type | Description |
---|---|---|
successCallback | function |
|
successCallback.deviceId | string |
The deviceId used by Marketing Cloud messaging. |
[errorCallback] | function |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Enables verbose logging within the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
See
Param | Type |
---|---|
[successCallback] | function |
[errorCallback] | function |
Disables verbose logging within the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
See
Param | Type |
---|---|
[successCallback] | function |
[errorCallback] | function |
Kind: static method of MCCordovaPlugin
Since: 6.1.0
Param | Type |
---|---|
notificationOpenedListener | function |
notificationOpenedListener.event | MCCordovaPlugin~notificationOpenedCallback |
Kind: static method of MCCordovaPlugin
Since: 6.3.0
Param | Type |
---|---|
urlActionListener | function |
urlActionListener.event | MCCordovaPlugin~urlActionCallback |
Instructs the native SDK to log the SDK state to the native logging system (Logcat for Android and Xcode/Console.app for iOS). This content can help diagnose most issues within the SDK and will be requested by the Marketing Cloud support team.
Kind: static method of MCCordovaPlugin
See
Since: 6.3.1
Param | Type |
---|---|
[successCallback] | function |
[errorCallback] | function |
Method to track events, which could result in actions such as an InApp Message being displayed.
Kind: static method of MCCordovaPlugin
See
Param | Type | Description |
---|---|---|
event | CustomEvent | EngagementEvent | IdentityEvent | SystemEvent | CartEvent | OrderEvent | CatalogObjectEvent |
The event to be tracked. |
Enables or disables analytics in the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
Param | Type | Description |
---|---|---|
enabled | boolean |
Whether analytics should be enabled. |
[successCallback] | function |
|
[errorCallback] | function |
Checks if analytics are enabled in the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
Param | Type |
---|---|
successCallback | function |
[errorCallback] | function |
Enables or disables PI analytics in the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
Param | Type | Description |
---|---|---|
enabled | boolean |
Whether PI analytics should be enabled. |
[successCallback] | function |
|
[errorCallback] | function |
Checks if PI analytics are enabled in the native Marketing Cloud SDK.
Kind: static method of MCCordovaPlugin
Param | Type |
---|---|
successCallback | function |
[errorCallback] | 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' |
Kind: inner typedef of MCCordovaPlugin
Param | Type | Description |
---|---|---|
url | string |
The url associated with the action taken by the user. |
Follow Capacitor guide for integrating with Capacitor or Ionic apps.
Where possible, we changed noninclusive terms to align with our company value of Equality. We retained noninclusive terms to document a third-party system, but we encourage the developer community to embrace more inclusive language. We can update the term when it’s no longer required for technical accuracy.