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.
-
Add the plugin to your application via npm.
-
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.
-
Download the
google-services.json
file from your application's Firebase console and place it in your project's root folder. -
Add the following to the
Android
element in yourconfig.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.
-
Navigate to
config.xml
. -
Update the
deployment-target
as shown in the following example. -
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.
- In Xcode, click File > New > Target.
- Select Notification Service Extension.
- 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"
.
-
-
Static Methods
.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 typedefs
-
The current state of the pushEnabled
flag in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type | Description |
---|---|---|
successCallback | function | |
successCallback.enabled | boolean | Whether push is enabled |
errorCallback | function |
Enables push messaging in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type |
---|---|
successCallback | function |
errorCallback | function |
Disables push messaging in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type |
---|---|
successCallback | function |
errorCallback | function |
This method returns the token used by Engagement to send push messages to the device.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type | Description |
---|---|---|
successCallback | function | |
successCallback.token | string | The token used for push messaging. |
errorCallback | function |
Returns the deviceId
used by the MobilePush SDK.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type | Description |
---|---|---|
successCallback | function | |
successCallback.deviceId | string | The deviceId used by Engagement messaging. |
errorCallback | function |
Returns the maps of attributes set in the registration.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | 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 Also
Parameter | 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 Also
Parameter | Type | Description |
---|---|---|
key | string | The name of the attribute whose value must 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 Also
Parameter | 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 Also
Parameter | 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 Also
Parameter | 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 Also
Parameter | 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 Also
Parameter | Type | Description |
---|---|---|
successCallback | function | |
successCallback.contactKey | string | The current contact key. |
errorCallback | function |
Enables verbose logging within the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type |
---|---|
successCallback | function |
errorCallback | function |
Disables verbose logging within the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
See Also
Parameter | Type |
---|---|
successCallback | function |
errorCallback | function |
Kind: Static method of MCCordovaPlugin
Since: 6.1.0
Parameter | Type |
---|---|
notificationOpenedListener | function |
notificationOpenedListener.event | MCCordovaPlugin~notificationOpenedCallback |
Kind: Static method of MCCordovaPlugin
Since: 6.3.0
Parameter | 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 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
Parameter | 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 Also
Parameter | Type | Description |
---|---|---|
event | CustomEvent | EngagementEvent | IdentityEvent | SystemEvent | CartEvent | OrderEvent | CatalogObjectEvent | The event to be tracked. |
Enables or disables analytics in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
Parameter | Type | Description |
---|---|---|
enabled | boolean | Whether to enable analytics |
successCallback | function | |
errorCallback | function |
Checks if analytics are enabled in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
Parameter | Type |
---|---|
successCallback | function |
errorCallback | function |
Enables or disables Predictive Intelligence (PI) analytics in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
Parameter | Type | Description |
---|---|---|
enabled | boolean | Whether to enable PI analytics |
successCallback | function | |
errorCallback | function |
Checks whether PI analytics are enabled in the native MobilePush SDK.
Kind: Static method of MCCordovaPlugin
Parameter | Type |
---|---|
successCallback | function |
errorCallback | function |
Kind: Inner typedef of MCCordovaPlugin
Parameter | Type | Description |
---|---|---|
timeStamp | number | Time since the 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. The URL can either be a CloudPages URL or an OpenDirect URL. |
values.type | string | Indicates the type of notification message. Possible values: cloudPage , openDirect , or other . |
Kind: Inner typedef of MCCordovaPlugin
Parameter | Type | Description |
---|---|---|
url | string | The 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.