Marketing Cloud Engagement SDK

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 

1MarketingCloudEngagementSdkModule.refreshInbox();

Returns 

  • Promise<boolean> - Indicates whether the refresh request succeeded.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5await mc.refreshInbox();

See Also 

getAllMessages 

Retrieves active inbox messages, including read and unread messages that are not deleted.

Syntax 

1MarketingCloudEngagementSdkModule.getAllMessages();

Returns 

  • Promise<InboxMessage[]> - A promise that resolves to the array of inbox messages.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const allMsgs: InboxMessage[] = await mc.getAllMessages();

See Also 

getUnreadMessages 

Retrieves active unread inbox messages that are not deleted.

Syntax 

1MarketingCloudEngagementSdkModule.getUnreadMessages();

Returns 

  • Promise<InboxMessage[]> - A promise that resolves to unread inbox messages.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const unreadMsgs: InboxMessage[] = await mc.getUnreadMessages();

See Also 

getReadMessages 

Retrieves active read inbox messages that are not deleted.

Syntax 

1MarketingCloudEngagementSdkModule.getReadMessages();

Returns 

  • Promise<InboxMessage[]> - A promise that resolves to read inbox messages.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const readMsgs: InboxMessage[] = await mc.getReadMessages();

See Also 

getDeletedMessages 

Retrieves active deleted inbox messages.

Syntax 

1MarketingCloudEngagementSdkModule.getDeletedMessages();

Returns 

  • Promise<InboxMessage[]> - A promise that resolves to deleted inbox messages.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const deletedMsgs: InboxMessage[] = await mc.getDeletedMessages();

See Also 

getMessageCount 

Retrieves the total number of inbox messages that are not deleted.

Syntax 

1MarketingCloudEngagementSdkModule.getMessageCount();

Returns 

  • Promise<number> - A promise that resolves to the message count.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const totalCount = await mc.getMessageCount();

See Also 

getUnreadMessageCount 

Retrieves the total number of unread inbox messages that are not deleted.

Syntax 

1MarketingCloudEngagementSdkModule.getUnreadMessageCount();

Returns 

  • Promise<number> - A promise that resolves to the unread message count.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const unreadCount = await mc.getUnreadMessageCount();

See Also 

getReadMessageCount 

Retrieves the total number of read inbox messages that are not deleted.

Syntax 

1MarketingCloudEngagementSdkModule.getReadMessageCount();

Returns 

  • Promise<number> - A promise that resolves to the read message count.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const readCount = await mc.getReadMessageCount();

See Also 

getDeletedMessageCount 

Retrieves the total number of deleted inbox messages.

Syntax 

1MarketingCloudEngagementSdkModule.getDeletedMessageCount();

Returns 

  • Promise<number> - A promise that resolves to the deleted message count.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const deletedCount = await mc.getDeletedMessageCount();

See Also 

markMessageRead 

Marks an inbox message as read in local storage.

Syntax 

1MarketingCloudEngagementSdkModule.markMessageRead(messageId);

Parameters 

ParameterTypeDescription
messageIdstringThe inbox message ID to mark as read.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.markMessageRead("message-id");

See Also 

markMessageDeleted 

Marks an inbox message as deleted in local storage.

Syntax 

1MarketingCloudEngagementSdkModule.markMessageDeleted(messageId);

Parameters 

ParameterTypeDescription
messageIdstringThe inbox message ID to mark as deleted.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.markMessageDeleted("message-id");

See Also 

markAllMessagesRead 

Marks all active unread inbox messages as read.

Syntax 

1MarketingCloudEngagementSdkModule.markAllMessagesRead();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.markAllMessagesRead();

See Also 

markAllMessagesDeleted 

Marks all active inbox messages as deleted.

Syntax 

1MarketingCloudEngagementSdkModule.markAllMessagesDeleted();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.markAllMessagesDeleted();

See Also 

trackInboxMessageOpened 

Tracks an inbox message-open event for analytics.

Syntax 

1MarketingCloudEngagementSdkModule.trackInboxMessageOpened(message);

Parameters 

ParameterTypeDescription
messageInboxMessageThe inbox message to track as opened. Include the message object returned by the inbox APIs.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi, InboxMessage } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const message: InboxMessage = { id: "message-id", read: false, deleted: false };
6mc.trackInboxMessageOpened(message);

See Also 

addTag 

Adds a tag to the registration tag list.

Syntax 

1MarketingCloudEngagementSdkModule.addTag(tag);

Parameters 

ParameterTypeDescription
tagstringThe tag to add to the registration tag list. Use a meaningful segmentation value, such as beta-tester.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.addTag("beta-tester");

See Also 

addTags 

Adds multiple tags to the registration tag list.

Syntax 

1MarketingCloudEngagementSdkModule.addTags(tags);

Parameters 

ParameterTypeDescription
tagsstring[]The tags to add to the registration tag list. Each array value is a segmentation tag string.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.addTags(["beta-tester", "vip-user"]);

See Also 

removeTag 

Removes a tag from the registration tag list.

Syntax 

1MarketingCloudEngagementSdkModule.removeTag(tag);

Parameters 

ParameterTypeDescription
tagstringThe tag to remove from the registration tag list. Use the exact tag value that is currently set.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.removeTag("beta-tester");

See Also 

removeTags 

Removes multiple tags from the registration tag list.

Syntax 

1MarketingCloudEngagementSdkModule.removeTags(tags);

Parameters 

ParameterTypeDescription
tagsstring[]The tags to remove from the registration tag list. Each array value must match a currently set tag.

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.removeTags(["beta-tester", "vip-user"]);

See Also 

getTags 

Returns the tags currently set on the device.

Syntax 

1MarketingCloudEngagementSdkModule.getTags();

Returns 

  • Promise<string[]> - A promise that resolves to tags currently set in the native SDK.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const tags = await mc.getTags();

See Also 

getAttributes 

Returns all attributes currently set in the device registration profile.

Syntax 

1MarketingCloudEngagementSdkModule.getAttributes();

Parameters 

None.

Returns 

  • Promise<object> - Object containing all attributes.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const attributes = await mc.getAttributes();

enablePiAnalytics 

Enables Predictive Intelligence analytics in the Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.enablePiAnalytics();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.enablePiAnalytics();

See Also 

disablePiAnalytics 

Disables Predictive Intelligence analytics in the Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.disablePiAnalytics();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.disablePiAnalytics();

See Also 

isPiAnalyticsEnabled 

Checks whether Predictive Intelligence analytics is enabled.

Syntax 

1MarketingCloudEngagementSdkModule.isPiAnalyticsEnabled();

Returns 

  • Promise<boolean> - A promise that resolves to whether PI analytics is enabled.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const piEnabled = await mc.isPiAnalyticsEnabled();

See Also 

enableAnalytics 

Enables analytics in the Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.enableAnalytics();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.enableAnalytics();

See Also 

disableAnalytics 

Disables analytics in the Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.disableAnalytics();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.disableAnalytics();

See Also 

isAnalyticsEnabled 

Checks whether analytics is enabled in the Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.isAnalyticsEnabled();

Returns 

  • Promise<boolean> - A promise that resolves to whether analytics is enabled.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const analyticsEnabled = await mc.isAnalyticsEnabled();

See Also 

getDeviceId 

Returns the device ID that Marketing Cloud uses for push messaging.

Syntax 

1MarketingCloudEngagementSdkModule.getDeviceId();

Returns 

  • Promise<string \| null> - A promise that resolves to the device ID, or null.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const deviceId = await mc.getDeviceId();

See Also 

getContactKey 

Returns the contact key currently set for the device user.

Syntax 

1MarketingCloudEngagementSdkModule.getContactKey();

Parameters 

None.

Returns 

  • Promise<string \| null> - Contact key, or null.

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5const contactKey = await mc.getContactKey();

enableLogging 

Enables verbose logging in the native Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.enableLogging();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.enableLogging();

See Also 

disableLogging 

Disables verbose logging in the native Marketing Cloud SDK.

Syntax 

1MarketingCloudEngagementSdkModule.disableLogging();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.disableLogging();

See Also 

setRegistrationCallback 

Registers a callback to receive registration change events from the SDK.

Syntax 

1MarketingCloudEngagementSdkModule.setRegistrationCallback();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.setRegistrationCallback();
6
7const sub = MarketingCloudSdkModule.getEmitter().addListener(
8  "sfmc_mc_registration",
9  (registration) => {
10    console.log("MC registration changed:", registration);
11  },
12);
13
14sub.remove();

See Also 

unsetRegistrationCallback 

Unregisters the registration change callback.

Syntax 

1MarketingCloudEngagementSdkModule.unsetRegistrationCallback();

Returns 

  • void

Example 

1import { MarketingCloudSdkModule } from "@sfmc/react-native-marketingcloudsdk";
2import type { MCApi } from "@sfmc/react-native-marketingcloudsdk";
3
4const mc: MCApi = await MarketingCloudSdkModule.requestSdk();
5mc.unsetRegistrationCallback();

See Also