DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
This section provides API reference details for SFMC Core module in React Native unified plugin.
Sets the profile identifier for the device user.
1SFMCSdkModule.setProfileId(profileId);| Parameter | Type | Description |
|---|---|---|
profileId | string | The profile ID (contact key) for the device user. Use a stable identifier, such as a CRM user ID or email-based key, so the same user is recognized across sessions. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setProfileId("user-1234");Returns the profile identifier currently set on the device.
1SFMCSdkModule.getProfileId();Promise<string \| null> - A promise that resolves to the current profile ID.1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const profileId = await sfmc.getProfileId();Sets an attribute value in the device user’s registration profile.
1SFMCSdkModule.setAttribute(key, value);| Parameter | Type | Description |
|---|---|---|
key | string | The attribute name in the registration profile. |
value | string | The attribute value to assign to key in the registration profile. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setAttribute("email", "sample@example.com");Sets multiple attribute values in the device user’s registration profile in one call.
1SFMCSdkModule.setAttributes(attributes);| Parameter | Type | Description |
|---|---|---|
attributes | object | The key-value map of identity attributes to set in one call. Each key is an attribute name and each value is a string attribute value. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setAttributes({
6 email: "sample@example.com",
7 tier: "gold",
8});Clears an attribute value from the device user’s registration profile.
1SFMCSdkModule.clearAttribute(key);| Parameter | Type | Description |
|---|---|---|
key | string | The attribute name whose value is cleared from the registration profile. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.clearAttribute("email");Clears all attributes from the device user’s registration profile.
1SFMCSdkModule.clearAllAttributes();void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.clearAllAttributes();Returns the attributes currently set in the device user’s registration profile.
1SFMCSdkModule.getAttributes();Promise<object \| null> - A promise that resolves to the attribute key-value map.1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const attributes = await sfmc.getAttributes();Sets the party identification name in the device user’s identity profile.
1SFMCSdkModule.setPartyIdentificationName(name);| Parameter | Type | Description |
|---|---|---|
name | string | The party identification name for the device user. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setPartyIdentificationName("Jane Doe");Sets the party identification number in the device user’s identity profile.
1SFMCSdkModule.setPartyIdentificationNumber(numberValue);| Parameter | Type | Description |
|---|---|---|
numberValue | string | The party identification number for the device user. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setPartyIdentificationNumber("PID-1001");Sets the party identification type in the device user’s identity profile.
1SFMCSdkModule.setPartyIdentificationType(type);| Parameter | Type | Description |
|---|---|---|
type | string | The party identification type for the device user. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setPartyIdentificationType("customer");Returns the party identification name currently set on the device.
1SFMCSdkModule.getPartyIdentificationName();Promise<string \| null> - A promise that resolves to the current party identification name.1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const partyName = await sfmc.getPartyIdentificationName();Returns the party identification number currently set on the device.
1SFMCSdkModule.getPartyIdentificationNumber();Promise<string \| null> - A promise that resolves to the current party identification number.1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const partyNumber = await sfmc.getPartyIdentificationNumber();Returns the party identification type currently set on the device.
1SFMCSdkModule.getPartyIdentificationType();Promise<string \| null> - A promise that resolves to the current party identification type.1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const partyType = await sfmc.getPartyIdentificationType();Tracks an event, which can trigger SDK actions such as in-app message display.
1SFMCSdkModule.track(event);| Parameter | Type | Description |
|---|---|---|
event | object | The SFMCEvent payload to track. Valid event types are CustomEvent, EngagementEvent, IdentityEvent, SystemEvent, CartEvent, OrderEvent, and CatalogObjectEvent. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi, SFMCEvent } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const event: SFMCEvent = { objType: "CustomEvent", name: "app_open" };
6sfmc.track(event);Tracks an event and sends it immediately without waiting for the next batch cycle.
1SFMCSdkModule.sendImmediate(event);| Parameter | Type | Description |
|---|---|---|
event | object | The SFMCEvent payload to track and send immediately. Valid event types are CustomEvent, EngagementEvent, IdentityEvent, SystemEvent, CartEvent, OrderEvent, and CatalogObjectEvent. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi, SFMCEvent } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const event: SFMCEvent = {
6 objType: "CartEvent",
7 subtype: "add",
8 lineItems: [
9 {
10 catalogObjectType: "Product",
11 catalogObjectId: "sku-1",
12 quantity: 2,
13 price: 9.99,
14 currency: "USD",
15 },
16 ],
17};
18sfmc.sendImmediate(event);Flushes all queued events to Marketing Cloud servers immediately.
1SFMCSdkModule.flush();void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.flush();Sets the log level for the native Marketing Cloud SDK and Unified SFMC SDK.
1SFMCSdkModule.setLogging(level);| Parameter | Type | Description |
|---|---|---|
level | string | The SDK log level. Valid values are DEBUG, WARN, ERROR, and NONE. |
void1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5sfmc.setLogging("DEBUG");Returns the current SDK state object for diagnostics and support troubleshooting.
1SFMCSdkModule.getSdkState();Promise<object> - A promise that resolves to the SDK state object.1import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
2import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";
3
4const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
5const sdkState = await sfmc.getSdkState();