Salesforce Marketing Cloud
Push notifications and engagement tracking with Salesforce Marketing Cloud
Integrate Salesforce Marketing Cloud MobilePush into your app to manage push notifications, user contact keys, custom attributes, and tags. Median's Salesforce Marketing Cloud Native Plugin wraps the iOS SDK and Android SDK to provide native push notification support with device registration and audience targeting.
The plugin enables you to prompt for push notification permissions, set and retrieve contact keys for user identification, manage custom attributes and tags for audience segmentation, and retrieve device registration information.
App Configuration
The Salesforce Marketing Cloud plugin requires your MobilePush app credentials. Configure them in the App Studio, on the Native Plugins tab under "Advanced Mode":
{
"salesforceCloud": {
"active": true,
"appID": "YOUR_APP_ID",
"accessToken": "YOUR_ACCESS_TOKEN",
"appEndpoint": "https://YOUR_ENDPOINT.push.salesforce.com",
"mid": "YOUR_MID",
"requiresUserPrivacyConsent": false,
"delayRegistrationUntilContactKeyIsSet": false
}
}| Parameter | Type | Description |
|---|---|---|
| active | boolean | Enable or disable the plugin. |
| appID | string | Your Salesforce Marketing Cloud App ID. |
| accessToken | string | Your Salesforce Marketing Cloud Access Token. |
| appEndpoint | string | Your Marketing Cloud push endpoint URL. |
| mid | string | Your Marketing Cloud MID (Member ID). |
| requiresUserPrivacyConsent | boolean | Optional. If true, the SDK waits for explicit user consent before initializing. Default: false. |
| delayRegistrationUntilContactKeyIsSet | boolean | Optional. If true, delays SDK registration until a contact key is set. Default: false. |
SDK InitializationThe Salesforce Marketing Cloud SDK is automatically initialized at app launch using the credentials from the server configuration. On iOS, if
requiresUserPrivacyConsentisfalse, the plugin also automatically prompts for notification permissions on first launch.
Implementation Guide
Prompt for Push Notifications
Request push notification permission from the user. On Android 13+ this triggers the system permission dialog. On older Android versions, notifications are enabled by default.
↔️Median JavaScript Bridge
To prompt for push notifications:
const result = await median.salesforceCloud.promptNotification(); // result object { granted: true | false }
Check Notification Status
Check whether push notifications are currently enabled for the app.
↔️Median JavaScript Bridge
To check notification status:
const result = await median.salesforceCloud.notificationEnabled(); // result object { granted: true | false }
Get Device Info
Retrieve the device registration information from the Salesforce Marketing Cloud SDK.
↔️Median JavaScript Bridge
To get device registration info:
const result = await median.salesforceCloud.getInfo(); // result object { deviceToken: "...", pushEnabled: true | false, deviceId: "...", notificationUserInfo: {} // iOS only }
Set Contact Key
Set the contact key (profile ID) to identify the user in Salesforce Marketing Cloud.
↔️Median JavaScript Bridge
To set a contact key:
const result = await median.salesforceCloud.contactKey.set({ contactKey: 'user_12345' }); // result object { success: true | false, error: "..." // present on failure }
Parameters
| Parameter | Type | Description |
|---|---|---|
| contactKey | string | Required. The contact key to identify the user. |
Get Contact Key
Retrieve the currently set contact key.
↔️Median JavaScript Bridge
To get the current contact key:
const result = await median.salesforceCloud.contactKey.get(); // result object { success: true | false, contactKey: "user_12345", error: "..." // present on failure (iOS) }
Set Attributes
Set custom profile attributes on the Salesforce contact for audience segmentation.
↔️Median JavaScript Bridge
To set attributes:
const result = await median.salesforceCloud.attributes.set({ attributes: { firstName: 'Jane', lastName: 'Doe', plan: 'premium' } }); // result object { success: true | false, error: "..." // present on failure }
Parameters
| Parameter | Type | Description |
|---|---|---|
| attributes | object | Required. Key-value pairs (all values must be strings). |
Get Attributes
Retrieve all profile attributes currently set on the device.
↔️Median JavaScript Bridge
To get attributes:
const result = await median.salesforceCloud.attributes.get(); // result object { success: true, attributes: { firstName: "Jane", lastName: "Doe", plan: "premium" } }
Set Tags
Add tags to the device for audience segmentation.
↔️Median JavaScript Bridge
To set tags:
// Add a single tag (iOS and Android) const result = await median.salesforceCloud.tags.set({ tag: 'premium_user' }); // Add multiple tags (Android only) const result = await median.salesforceCloud.tags.set({ tags: ['premium_user', 'newsletter_subscriber', 'beta_tester'] }); // result object { success: true | false, error: "..." // present on failure }
Parameters
| Parameter | Type | Description |
|---|---|---|
| tag | string | Optional. A single tag to add (iOS and Android). |
| tags | string[] | Optional. An array of tags to add (Android only). |
Platform DifferencesOn iOS, only the
tagparameter is supported (single tag at a time). On Android, bothtagandtagsare supported. Passing an emptytagsarray on Android will clear all existing tags.
Get Tags
Retrieve all tags currently set on the device.
↔️Median JavaScript Bridge
To get tags:
const result = await median.salesforceCloud.tags.get(); // result object { success: true, tags: ["premium_user", "newsletter_subscriber"] }
Delete a Tag (iOS Only)
Remove a single tag from the device registration. This method is only available on iOS.
↔️Median JavaScript Bridge
To delete a tag:
const result = await median.salesforceCloud.tags.delete({ tag: 'premium_user' }); // result object { success: true | false, error: "..." // present on failure }
Parameters
| Parameter | Type | Description |
|---|---|---|
| tag | string | Required. The tag to remove. |
Updated 1 day ago