7.1.0 • Published 3 years ago

@cognifit/cordova-plugin-marketingcloudsdk v7.1.0

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
3 years ago

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

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

2. Modify your application's config.xml to configure the plugin

<!-- 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}" />

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>

4. Enable iOS Push

Follow these instructions to enable push for iOS.

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

ParamTypeDescription
successCallbackfunction
successCallback.enabledbooleanWhether push is enabled.
errorCallbackfunction

MCCordovaPlugin.requestPushPermission(successCallback, errorCallback)

Requests iOS/iPadOS to ask the user to enable push notifications for the App. The user will be prompted only once.

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
successCallbackfunction
successCallback.grantedbooleanWhether permission to receive push notifications was granted.
errorCallbackfunction

MCCordovaPlugin.getPushNotificationSettings(successCallback, errorCallback)

Gets the notification settings for this app. Applies only to iOS/iPadOS.

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
successCallbackfunction
successCallback.statusstringOne of the following values: 'not-determined', 'denied', 'authorized', 'provisional'.
errorCallbackfunction

MCCordovaPlugin.enablePush(successCallback, errorCallback)

Enables push messaging in the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin
See

ParamType
successCallbackfunction
errorCallbackfunction

MCCordovaPlugin.disablePush(successCallback, errorCallback)

Disables push messaging in the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin
See

ParamType
successCallbackfunction
errorCallbackfunction

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

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

MCCordovaPlugin.getAttributes(successCallback, errorCallback)

Returns the maps of attributes set in the registration.

Kind: static method of MCCordovaPlugin
See

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

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

Sets the value of an attribute in the registration.

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
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

MCCordovaPlugin.clearAttribute(key, successCallback, errorCallback)

Clears the value of an attribute in the registration.

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
keystringThe name of the attribute whose value should be cleared from the registration.
successCallbackfunction
successCallback.savedbooleanWhether the value of the key attribute was cleared from the registration.
errorCallbackfunction

MCCordovaPlugin.addTag(tag, successCallback, errorCallback)

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
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

MCCordovaPlugin.removeTag(tag, successCallback, errorCallback)

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
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

MCCordovaPlugin.getTags(successCallback, errorCallback)

Returns the tags currently set on the device.

Kind: static method of MCCordovaPlugin
See

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

MCCordovaPlugin.setContactKey(contactKey, successCallback, errorCallback)

Sets the contact key for the device's user.

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
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

MCCordovaPlugin.getContactKey(successCallback, errorCallback)

Returns the contact key currently set on the device.

Kind: static method of MCCordovaPlugin
See

ParamTypeDescription
successCallbackfunction
successCallback.contactKeystringThe current contact key.
errorCallbackfunction

MCCordovaPlugin.enableVerboseLogging(successCallback, errorCallback)

Enables verbose logging within the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin
See

ParamType
successCallbackfunction
errorCallbackfunction

MCCordovaPlugin.disableVerboseLogging(successCallback, errorCallback)

Disables verbose logging within the native Marketing Cloud SDK.

Kind: static method of MCCordovaPlugin
See

ParamType
successCallbackfunction
errorCallbackfunction

MCCordovaPlugin.setOnNotificationOpenedListener(notificationOpenedListener)

Kind: static method of MCCordovaPlugin
Since: 6.1.0

ParamType
notificationOpenedListenerfunction
notificationOpenedListener.eventMCCordovaPlugin~notificationOpenedCallback

MCCordovaPlugin.setOnUrlActionListener(urlActionListener)

Kind: static method of MCCordovaPlugin
Since: 6.3.0

ParamType
urlActionListenerfunction
urlActionListener.eventMCCordovaPlugin~urlActionCallback

MCCordovaPlugin.logSdkState(successCallback, errorCallback)

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
Since: 6.3.1

ParamType
successCallbackfunction
errorCallbackfunction

MCCordovaPlugin~notificationOpenedCallback : function

Kind: inner typedef of MCCordovaPlugin

ParamTypeDescription
timeStampnumberTime since 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. This can be either a cloud-page url or an open-direct url.
values.typestringIndicates the type of notification message. Possible values: 'cloudPage', 'openDirect' or 'other'

MCCordovaPlugin~urlActionCallback : function

Kind: inner typedef of MCCordovaPlugin

ParamTypeDescription
urlstringThe url associated with the action taken by the user.