This section provides API reference details for the Marketing Cloud Engagement SDK module in React Native unified plugin.
refreshInbox
Requests an updated list of inbox messages from the Marketing Cloud servers.
Syntax
MarketingCloudEngagementSdkModule.refreshInbox();
Returns
Promise<boolean>- Indicates whether the refresh request succeeded.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
await mc.refreshInbox();
See Also
getAllMessages
Retrieves active inbox messages, including read and unread messages that are not deleted.
Syntax
MarketingCloudEngagementSdkModule.getAllMessages();
Returns
Promise<InboxMessage[]>- A promise that resolves to the array of inbox messages.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const allMsgs: InboxMessage[] = await mc.getAllMessages();
See Also
getUnreadMessages
Retrieves active unread inbox messages that are not deleted.
Syntax
MarketingCloudEngagementSdkModule.getUnreadMessages();
Returns
Promise<InboxMessage[]>- A promise that resolves to unread inbox messages.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const unreadMsgs: InboxMessage[] = await mc.getUnreadMessages();
See Also
getReadMessages
Retrieves active read inbox messages that are not deleted.
Syntax
MarketingCloudEngagementSdkModule.getReadMessages();
Returns
Promise<InboxMessage[]>- A promise that resolves to read inbox messages.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const readMsgs: InboxMessage[] = await mc.getReadMessages();
See Also
getDeletedMessages
Retrieves active deleted inbox messages.
Syntax
MarketingCloudEngagementSdkModule.getDeletedMessages();
Returns
Promise<InboxMessage[]>- A promise that resolves to deleted inbox messages.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const deletedMsgs: InboxMessage[] = await mc.getDeletedMessages();
See Also
getMessageCount
Retrieves the total number of inbox messages that are not deleted.
Syntax
MarketingCloudEngagementSdkModule.getMessageCount();
Returns
Promise<number>- A promise that resolves to the message count.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const totalCount = await mc.getMessageCount();
See Also
getUnreadMessageCount
Retrieves the total number of unread inbox messages that are not deleted.
Syntax
MarketingCloudEngagementSdkModule.getUnreadMessageCount();
Returns
Promise<number>- A promise that resolves to the unread message count.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const unreadCount = await mc.getUnreadMessageCount();
See Also
getReadMessageCount
Retrieves the total number of read inbox messages that are not deleted.
Syntax
MarketingCloudEngagementSdkModule.getReadMessageCount();
Returns
Promise<number>- A promise that resolves to the read message count.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const readCount = await mc.getReadMessageCount();
See Also
getDeletedMessageCount
Retrieves the total number of deleted inbox messages.
Syntax
MarketingCloudEngagementSdkModule.getDeletedMessageCount();
Returns
Promise<number>- A promise that resolves to the deleted message count.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const deletedCount = await mc.getDeletedMessageCount();
See Also
markMessageRead
Marks an inbox message as read in local storage.
Syntax
MarketingCloudEngagementSdkModule.markMessageRead(messageId);
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId |
string |
The inbox message ID to mark as read. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.markMessageRead("message-id");
See Also
markMessageDeleted
Marks an inbox message as deleted in local storage.
Syntax
MarketingCloudEngagementSdkModule.markMessageDeleted(messageId);
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId |
string |
The inbox message ID to mark as deleted. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.markMessageDeleted("message-id");
See Also
markAllMessagesRead
Marks all active unread inbox messages as read.
Syntax
MarketingCloudEngagementSdkModule.markAllMessagesRead();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.markAllMessagesRead();
See Also
markAllMessagesDeleted
Marks all active inbox messages as deleted.
Syntax
MarketingCloudEngagementSdkModule.markAllMessagesDeleted();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.markAllMessagesDeleted();
See Also
trackInboxMessageOpened
Tracks an inbox message-open event for analytics.
Syntax
MarketingCloudEngagementSdkModule.trackInboxMessageOpened(message);
Parameters
| Parameter | Type | Description |
|---|---|---|
message |
InboxMessage |
The inbox message to track as opened. Include the message object returned by the inbox APIs. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const message: InboxMessage = { id: "message-id", read: false, deleted: false };
mc.trackInboxMessageOpened(message);
See Also
addTag
Adds a tag to the registration tag list.
Syntax
MarketingCloudEngagementSdkModule.addTag(tag);
Parameters
| Parameter | Type | Description |
|---|---|---|
tag |
string |
The tag to add to the registration tag list. Use a meaningful segmentation value, such as beta-tester. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.addTag("beta-tester");
See Also
addTags
Adds multiple tags to the registration tag list.
Syntax
MarketingCloudEngagementSdkModule.addTags(tags);
Parameters
| Parameter | Type | Description |
|---|---|---|
tags |
string[] |
The tags to add to the registration tag list. Each array value is a segmentation tag string. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.addTags(["beta-tester", "vip-user"]);
See Also
removeTag
Removes a tag from the registration tag list.
Syntax
MarketingCloudEngagementSdkModule.removeTag(tag);
Parameters
| Parameter | Type | Description |
|---|---|---|
tag |
string |
The tag to remove from the registration tag list. Use the exact tag value that is currently set. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.removeTag("beta-tester");
See Also
removeTags
Removes multiple tags from the registration tag list.
Syntax
MarketingCloudEngagementSdkModule.removeTags(tags);
Parameters
| Parameter | Type | Description |
|---|---|---|
tags |
string[] |
The tags to remove from the registration tag list. Each array value must match a currently set tag. |
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.removeTags(["beta-tester", "vip-user"]);
See Also
getTags
Returns the tags currently set on the device.
Syntax
MarketingCloudEngagementSdkModule.getTags();
Returns
Promise<string[]>- A promise that resolves to tags currently set in the native SDK.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const tags = await mc.getTags();
See Also
getAttributes
Returns all attributes currently set in the device registration profile.
Syntax
MarketingCloudEngagementSdkModule.getAttributes();
Parameters
None.
Returns
Promise<object>- Object containing all attributes.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const attributes = await mc.getAttributes();
enablePiAnalytics
Enables Predictive Intelligence analytics in the Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.enablePiAnalytics();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.enablePiAnalytics();
See Also
disablePiAnalytics
Disables Predictive Intelligence analytics in the Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.disablePiAnalytics();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.disablePiAnalytics();
See Also
isPiAnalyticsEnabled
Checks whether Predictive Intelligence analytics is enabled.
Syntax
MarketingCloudEngagementSdkModule.isPiAnalyticsEnabled();
Returns
Promise<boolean>- A promise that resolves to whether PI analytics is enabled.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const piEnabled = await mc.isPiAnalyticsEnabled();
See Also
enableAnalytics
Enables analytics in the Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.enableAnalytics();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.enableAnalytics();
See Also
disableAnalytics
Disables analytics in the Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.disableAnalytics();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.disableAnalytics();
See Also
isAnalyticsEnabled
Checks whether analytics is enabled in the Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.isAnalyticsEnabled();
Returns
Promise<boolean>- A promise that resolves to whether analytics is enabled.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const analyticsEnabled = await mc.isAnalyticsEnabled();
See Also
getDeviceId
Returns the device ID that Marketing Cloud uses for push messaging.
Syntax
MarketingCloudEngagementSdkModule.getDeviceId();
Returns
Promise<string \| null>- A promise that resolves to the device ID, ornull.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const deviceId = await mc.getDeviceId();
See Also
getContactKey
Returns the contact key currently set for the device user.
Syntax
MarketingCloudEngagementSdkModule.getContactKey();
Parameters
None.
Returns
Promise<string \| null>- Contact key, ornull.
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
const contactKey = await mc.getContactKey();
enableLogging
Enables verbose logging in the native Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.enableLogging();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.enableLogging();
See Also
disableLogging
Disables verbose logging in the native Marketing Cloud SDK.
Syntax
MarketingCloudEngagementSdkModule.disableLogging();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.disableLogging();
See Also
setRegistrationCallback
Registers a callback to receive registration change events from the SDK.
Syntax
MarketingCloudEngagementSdkModule.setRegistrationCallback();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.setRegistrationCallback();
const sub = MarketingCloudSdkModule.getEmitter().addListener(
"sfmc_mc_registration",
(registration) => {
console.log("MC registration changed:", registration);
},
);
sub.remove();
See Also
unsetRegistrationCallback
Unregisters the registration change callback.
Syntax
MarketingCloudEngagementSdkModule.unsetRegistrationCallback();
Returns
void
Example
import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
mc.unsetRegistrationCallback();