A Cordova Plugin to access the native Salesforce Marketing Cloud MobilePush SDKs
npm install cordova-plugin-marketingcloudsdkUse 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
``shell`
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:
`shell`
sudo gem install cocoapods
pod repo update
#### 2. Modify your application's config.xml to configure the plugin
`xml
`
#### 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:
`xml`
#### 4. Enable Rich Notifications
Follow these instructions to enable rich notifications for iOS.
* MCCordovaPlugin
* _static_
* [.isPushEnabled(successCallback, [errorCallback])](#module_MCCordovaPlugin.isPushEnabled)
* [.enablePush([successCallback], [errorCallback])](#module_MCCordovaPlugin.enablePush)
* [.disablePush([successCallback], [errorCallback])](#module_MCCordovaPlugin.disablePush)
* [.getSystemToken(successCallback, [errorCallback])](#module_MCCordovaPlugin.getSystemToken)
* [.getDeviceId(successCallback, [errorCallback])](#module_MCCordovaPlugin.getDeviceId)
* [.getAttributes(successCallback, [errorCallback])](#module_MCCordovaPlugin.getAttributes)
* [.setAttribute(key, value, [successCallback], [errorCallback])](#module_MCCordovaPlugin.setAttribute)
* [.clearAttribute(key, [successCallback], [errorCallback])](#module_MCCordovaPlugin.clearAttribute)
* [.addTag(tag, [successCallback], [errorCallback])](#module_MCCordovaPlugin.addTag)
* [.removeTag(tag, [successCallback], [errorCallback])](#module_MCCordovaPlugin.removeTag)
* [.getTags(successCallback, [errorCallback])](#module_MCCordovaPlugin.getTags)
* [.setContactKey(contactKey, [successCallback], [errorCallback])](#module_MCCordovaPlugin.setContactKey)
* [.getContactKey(successCallback, [errorCallback])](#module_MCCordovaPlugin.getContactKey)
* [.enableLogging([successCallback], [errorCallback])](#module_MCCordovaPlugin.enableLogging)
* [.disableLogging([successCallback], [errorCallback])](#module_MCCordovaPlugin.disableLogging)
* .setOnNotificationOpenedListener(notificationOpenedListener)
* .setOnUrlActionListener(urlActionListener)
* [.logSdkState([successCallback], [errorCallback])](#module_MCCordovaPlugin.logSdkState)
* .track(event)
* [.setAnalyticsEnabled(enabled, [successCallback], [errorCallback])](#module_MCCordovaPlugin.setAnalyticsEnabled)
* [.isAnalyticsEnabled(successCallback, [errorCallback])](#module_MCCordovaPlugin.isAnalyticsEnabled)
* [.setPiAnalyticsEnabled(enabled, [successCallback], [errorCallback])](#module_MCCordovaPlugin.setPiAnalyticsEnabled)
* [.isPiAnalyticsEnabled(successCallback, [errorCallback])](#module_MCCordovaPlugin.isPiAnalyticsEnabled)
* _inner_
* ~notificationOpenedCallback : function
* ~urlActionCallback : function
---
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)pushEnabled)
| Param | Type | Description |
| --- | --- | --- |
| successCallback | function | |
| successCallback.enabled | boolean | Whether push is enabled. |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)setPushEnabled:)
| Param | Type |
| --- | --- |
| [successCallback] | function |
| [errorCallback] | function |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)setPushEnabled:)
| Param | Type |
| --- | --- |
| [successCallback] | function |
| [errorCallback] | function |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)deviceToken)
| Param | Type | Description |
| --- | --- | --- |
| successCallback | function | |
| successCallback.token | string | The token used for push messaging. |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)deviceIdentifier)
| Param | Type | Description |
| --- | --- | --- |
| successCallback | function | |
| successCallback.deviceId | string | The deviceId used by Marketing Cloud messaging. |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)attributes)
| Param | Type | Description |
| --- | --- | --- |
| successCallback | function | |
| successCallback.attributes | Object.<string, string> | The key/value map of attributes set in the registration. |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkIDENTITY(im)setProfileAttributes:)
| 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 | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkIDENTITY(im)clearProfileAttributeWithKey:)
| 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 - Android Docs
- iOS DocsSFMCSdkPushModule(im)addTag:)
| 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 - Android Docs
- iOS DocsSFMCSdkPushModule(im)removeTag:)
| 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 | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)tags)
| Param | Type | Description |
| --- | --- | --- |
| successCallback | function | |
| successCallback.tags | Array.<string> | The array of tags currently set in the native SDK. |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkIDENTITY(im)setProfileId:)
| 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 | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdkPushModule(im)contactKey)
| Param | Type | Description |
| --- | --- | --- |
| successCallback | function | |
| successCallback.contactKey | string | The current contact key. |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdk(cm)setLoggerWithLogLevel:logOutputter:)
| Param | Type |
| --- | --- |
| [successCallback] | function |
| [errorCallback] | function |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdk(cm)setLoggerWithLogLevel:logOutputter:)
| Param | Type |
| --- | --- |
| [successCallback] | function |
| [errorCallback] | function |
MCCordovaPlugin | Param | Type |
| --- | --- |
| notificationOpenedListener | function |
| notificationOpenedListener.event | MCCordovaPlugin~notificationOpenedCallback |
MCCordovaPlugin | Param | Type |
| --- | --- |
| urlActionListener | function |
| urlActionListener.event | MCCordovaPlugin~urlActionCallback |
Kind: static method of MCCordovaPlugin
See
- Android Docs
- iOS DocsSFMCSdk(cm)setLoggerWithLogLevel:logOutputter:https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledocs/SFMCSdk/8.0/Classes/SFMCSdk.html#/c:@M@SFMCSDK@objc(cs)SFMCSdk(cm)state)
Since: 6.3.1
| Param | Type |
| --- | --- |
| [successCallback] | function |
| [errorCallback] | function |
Kind: static method of MCCordovaPlugin
See
| Param | Type | Description |
| --- | --- | --- |
| event | CustomEvent \| EngagementEvent \| IdentityEvent \| SystemEvent \| CartEvent \| OrderEvent \| CatalogObjectEvent | The event to be tracked. |
Kind: static method of MCCordovaPlugin
| Param | Type | Description |
| --- | --- | --- |
| enabled | boolean | Whether analytics should be enabled. |
| [successCallback] | function | |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
| Param | Type |
| --- | --- |
| successCallback | function |
| [errorCallback] | function |
Kind: static method of MCCordovaPlugin
| Param | Type | Description |
| --- | --- | --- |
| enabled | boolean | Whether PI analytics should be enabled. |
| [successCallback] | function | |
| [errorCallback] | function | |
Kind: static method of MCCordovaPlugin
| Param | Type |
| --- | --- |
| successCallback | function |
| [errorCallback] | function |
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' |
MCCordovaPlugin | Param | Type | Description |
| --- | --- | --- |
| url | string | The url associated with the action taken by the user. |
---