SFMC Core

This section provides API reference details for SFMC Core module in React Native unified plugin.

setProfileId 

Sets the profile identifier for the device user.

Syntax 

1SFMCSdkModule.setProfileId(profileId);

Parameters 

ParameterTypeDescription
profileIdstringThe 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.

Returns 

  • void

Example 

1import { 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");

See Also 

getProfileId 

Returns the profile identifier currently set on the device.

Syntax 

1SFMCSdkModule.getProfileId();

Returns 

  • Promise<string \| null> - A promise that resolves to the current profile ID.

Example 

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();

See Also 

setAttribute 

Sets an attribute value in the device user’s registration profile.

Syntax 

1SFMCSdkModule.setAttribute(key, value);

Parameters 

ParameterTypeDescription
keystringThe attribute name in the registration profile.
valuestringThe attribute value to assign to key in the registration profile.

Returns 

  • void

Example 

1import { 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");

See Also 

setAttributes 

Sets multiple attribute values in the device user’s registration profile in one call.

Syntax 

1SFMCSdkModule.setAttributes(attributes);

Parameters 

ParameterTypeDescription
attributesobjectThe 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.

Returns 

  • void

Example 

1import { 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});

See Also 

clearAttribute 

Clears an attribute value from the device user’s registration profile.

Syntax 

1SFMCSdkModule.clearAttribute(key);

Parameters 

ParameterTypeDescription
keystringThe attribute name whose value is cleared from the registration profile.

Returns 

  • void

Example 

1import { 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");

See Also 

clearAllAttributes 

Clears all attributes from the device user’s registration profile.

Syntax 

1SFMCSdkModule.clearAllAttributes();

Returns 

  • void

Example 

1import { 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();

See Also 

getAttributes 

Returns the attributes currently set in the device user’s registration profile.

Syntax 

1SFMCSdkModule.getAttributes();

Returns 

  • Promise<object \| null> - A promise that resolves to the attribute key-value map.

Example 

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();

See Also 

setPartyIdentificationName 

Sets the party identification name in the device user’s identity profile.

Syntax 

1SFMCSdkModule.setPartyIdentificationName(name);

Parameters 

ParameterTypeDescription
namestringThe party identification name for the device user.

Returns 

  • void

Example 

1import { 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");

See Also 

setPartyIdentificationNumber 

Sets the party identification number in the device user’s identity profile.

Syntax 

1SFMCSdkModule.setPartyIdentificationNumber(numberValue);

Parameters 

ParameterTypeDescription
numberValuestringThe party identification number for the device user.

Returns 

  • void

Example 

1import { 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");

See Also 

setPartyIdentificationType 

Sets the party identification type in the device user’s identity profile.

Syntax 

1SFMCSdkModule.setPartyIdentificationType(type);

Parameters 

ParameterTypeDescription
typestringThe party identification type for the device user.

Returns 

  • void

Example 

1import { 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");

See Also 

getPartyIdentificationName 

Returns the party identification name currently set on the device.

Syntax 

1SFMCSdkModule.getPartyIdentificationName();

Returns 

  • Promise<string \| null> - A promise that resolves to the current party identification name.

Example 

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();

See Also 

getPartyIdentificationNumber 

Returns the party identification number currently set on the device.

Syntax 

1SFMCSdkModule.getPartyIdentificationNumber();

Returns 

  • Promise<string \| null> - A promise that resolves to the current party identification number.

Example 

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();

See Also 

getPartyIdentificationType 

Returns the party identification type currently set on the device.

Syntax 

1SFMCSdkModule.getPartyIdentificationType();

Returns 

  • Promise<string \| null> - A promise that resolves to the current party identification type.

Example 

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();

See Also 

track 

Tracks an event, which can trigger SDK actions such as in-app message display.

Syntax 

1SFMCSdkModule.track(event);

Parameters 

ParameterTypeDescription
eventobjectThe SFMCEvent payload to track. Valid event types are CustomEvent, EngagementEvent, IdentityEvent, SystemEvent, CartEvent, OrderEvent, and CatalogObjectEvent.

Returns 

  • void

Example 

1import { 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);

See Also 

sendImmediate 

Tracks an event and sends it immediately without waiting for the next batch cycle.

Syntax 

1SFMCSdkModule.sendImmediate(event);

Parameters 

ParameterTypeDescription
eventobjectThe SFMCEvent payload to track and send immediately. Valid event types are CustomEvent, EngagementEvent, IdentityEvent, SystemEvent, CartEvent, OrderEvent, and CatalogObjectEvent.

Returns 

  • void

Example 

1import { 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);

See Also 

flush 

Flushes all queued events to Marketing Cloud servers immediately.

Syntax 

1SFMCSdkModule.flush();

Returns 

  • void

Example 

1import { 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();

See Also 

setLogging 

Sets the log level for the native Marketing Cloud SDK and Unified SFMC SDK.

Syntax 

1SFMCSdkModule.setLogging(level);

Parameters 

ParameterTypeDescription
levelstringThe SDK log level. Valid values are DEBUG, WARN, ERROR, and NONE.

Returns 

  • void

Example 

1import { 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");

See Also 

getSdkState 

Returns the current SDK state object for diagnostics and support troubleshooting.

Syntax 

1SFMCSdkModule.getSdkState();

Returns 

  • Promise<object> - A promise that resolves to the SDK state object.

Example 

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();

See Also