MobilePush Cordova Plugin

Use the MobilePush Cordova Plugin to implement the MobilePush SDK for your Android and iOS applications. This guide provides detailed plugin installation and platform-specific setup instructions for integrating the Cordova Plugin into your app.

To install the Cordova plugin in your app, follow these steps.

  1. Add the plugin to your application via npm.

  2. To configure the plugin, modify your application's config.xml.

To enable push support for the Android platform, you must provide your Firebase Cloud Messaging (FCM) credentials by including the google-services.json file in your config.xml file.

  1. Download the google-services.json file from your application's Firebase console and place it in your project's root folder.

  2. Add the following to the Android element in your config.xml.

For iOS integrations, you must have CocoaPods installed. To install CocoaPods, run the following commands using a command-line interface.

Starting May 1, 2024, Apple requires all third-party frameworks to include a Privacy Manifest. MobilePush SDK version 8.1.2 complies with this requirement. It features a signed framework, a Privacy Manifest, and requires a deployment target of iOS 12 or later. By default, the Cordova Plugin automatically fetches the most recent version of the SDK, as long as the SDK’s minimum deployment target requirement is satisfied.

To ensure compatibility with the Privacy Manifest in SDK versions 8.1.2 or later, your application must support a deployment target of iOS 12 or higher.

To update the deployment target, follow these steps.

Following these steps eliminates support for iOS 11.0 or earlier, depending on your app's previous configurations.

  1. Navigate to config.xml.

  2. Update the deployment-target as shown in the following example.

  3. Remove and then readd the iOS platform using the command line.

Rich notifications include images, videos, titles and subtitles from the Marketing Cloud Engagement app, and mutable content. Mutable content can include personalization in the title, subtitle, or body of your message. To enable rich notifications, follow these steps.

  1. In Xcode, click File > New > Target.
  2. Select Notification Service Extension.
  3. Name and save the new extension.

You must perform these steps each time you add the platform to your Cordova application.

This service extension checks for a "_mediaUrl" element in request.content.userInfo. If it's present, the extension attempts to download media from the URL, creates a thumbnail-size version, and then adds the attachment. Additionally, the service extension also checks for a "_mediaAlt" element in request.content.userInfo. If this key is found, the service extension uses the element for the body text, in case there are any problems downloading or creating the media attachment.

A service extension can time out when it's unable to download media. In the following example, the service extension delivers the original content but replaces the body text with the value from "_mediaAlt".


The current state of the pushEnabled flag in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
successCallback function
successCallback.enabledbooleanWhether push is enabled
errorCallbackfunction

Enables push messaging in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

See Also

ParameterType
successCallbackfunction
errorCallbackfunction

Disables push messaging in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

See Also

ParameterType
successCallbackfunction
errorCallbackfunction

This method returns the token used by Engagement to send push messages to the device.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
successCallbackfunction
successCallback.tokenstringThe token used for push messaging.
errorCallbackfunction

Returns the deviceId used by the MobilePush SDK.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
successCallbackfunction
successCallback.deviceIdstringThe deviceId used by Engagement messaging.
errorCallbackfunction

Returns the maps of attributes set in the registration.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
successCallbackfunction
successCallback.attributesObject.<string, string>The key-value map of attributes set in the registration.
errorCallbackfunction

Sets the value of an attribute in the registration.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
keystringThe name of the attribute to be set in the registration.
valuestringThe value of the key attribute to be set in the registration.
successCallbackfunction
successCallback.savedbooleanWhether the attribute value was set in the registration.
errorCallbackfunction

Clears the value of an attribute in the registration.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
keystringThe name of the attribute whose value must be cleared from the registration.
successCallbackfunction
successCallback.saved booleanWhether the value of the key attribute was cleared from the registration.
errorCallbackfunction

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
tagstringThe tag to be added to the list of tags in the registration.
successCallbackfunction
successCallback.savedbooleanWhether the value passed in for tag was saved in the registration.
errorCallbackfunction

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
tagstringThe tag to be removed from the list of tags in the registration.
successCallbackfunction
successCallback.savedbooleanWhether the value passed in for tag was cleared from the registration.
errorCallbackfunction

Returns the tags currently set on the device.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
successCallbackfunction
successCallback.tagsArray.<string>The array of tags currently set in the native SDK.
errorCallbackfunction

Sets the contact key for the device's user.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
contactKeystringThe value to be set as the contact key of the device's user.
successCallbackfunction
successCallback.savedbooleanWhether the value passed in for contactKey was saved in the registration.
errorCallbackfunction

Returns the contact key currently set on the device.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
successCallbackfunction
successCallback.contactKeystringThe current contact key.
errorCallbackfunction

Enables verbose logging within the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

See Also

ParameterType
successCallbackfunction
errorCallbackfunction

Disables verbose logging within the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

See Also

ParameterType
successCallbackfunction
errorCallbackfunction

Kind: Static method of MCCordovaPlugin

Since: 6.1.0

ParameterType
notificationOpenedListenerfunction
notificationOpenedListener.eventMCCordovaPlugin~notificationOpenedCallback

Kind: Static method of MCCordovaPlugin

Since: 6.3.0

ParameterType
urlActionListenerfunction
urlActionListener.eventMCCordovaPlugin~urlActionCallback

Instructs the native SDK to log the SDK state to the native logging system (Logcat for Android and Xcode or Console for iOS). The Engagement Support team requests for the SDK state logs during support calls as they can help diagnose most issues.

Kind: Static method of MCCordovaPlugin

See Also

Since: 6.3.1

ParameterType
successCallbackfunction
errorCallbackfunction

Method to track events, which could result in actions such as an InApp Message being displayed.

Kind: Static method of MCCordovaPlugin

See Also

ParameterTypeDescription
eventCustomEvent| EngagementEvent| IdentityEvent | SystemEvent | CartEvent | OrderEvent | CatalogObjectEventThe event to be tracked.

Enables or disables analytics in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

ParameterTypeDescription
enabledbooleanWhether to enable analytics
successCallbackfunction
errorCallbackfunction

Checks if analytics are enabled in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

ParameterType
successCallbackfunction
errorCallbackfunction

Enables or disables Predictive Intelligence (PI) analytics in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

ParameterTypeDescription
enabledbooleanWhether to enable PI analytics
successCallbackfunction
errorCallbackfunction

Checks whether PI analytics are enabled in the native MobilePush SDK.

Kind: Static method of MCCordovaPlugin

ParameterType
successCallbackfunction
errorCallbackfunction

Kind: Inner typedef of MCCordovaPlugin

ParameterTypeDescription
timeStampnumberTime since the epoch when the push message was opened.
valuesObjectThe values of the notification message.
values.alertstringThe alert text of the notification message.
values.titlestringThe title text of the notification message.
values.urlstringThe URL associated with the notification message. The URL can either be a CloudPages URL or an OpenDirect URL.
values.typestringIndicates the type of notification message. Possible values: cloudPage, openDirect, or other.

Kind: Inner typedef of MCCordovaPlugin

ParameterTypeDescription
urlstringThe URL associated with the action taken by the user.

Where possible, we've 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.