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

SFMCSdkModule.setProfileId(profileId);

Parameters

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.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setProfileId("user-1234");

See Also

getProfileId

Returns the profile identifier currently set on the device.

Syntax

SFMCSdkModule.getProfileId();

Returns

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

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const profileId = await sfmc.getProfileId();

See Also

setAttribute

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

Syntax

SFMCSdkModule.setAttribute(key, value);

Parameters

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.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setAttribute("email", "sample@example.com");

See Also

setAttributes

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

Syntax

SFMCSdkModule.setAttributes(attributes);

Parameters

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.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setAttributes({
  email: "sample@example.com",
  tier: "gold",
});

See Also

clearAttribute

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

Syntax

SFMCSdkModule.clearAttribute(key);

Parameters

Parameter Type Description
key string The attribute name whose value is cleared from the registration profile.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.clearAttribute("email");

See Also

clearAllAttributes

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

Syntax

SFMCSdkModule.clearAllAttributes();

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.clearAllAttributes();

See Also

getAttributes

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

Syntax

SFMCSdkModule.getAttributes();

Returns

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

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const attributes = await sfmc.getAttributes();

See Also

setPartyIdentificationName

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

Syntax

SFMCSdkModule.setPartyIdentificationName(name);

Parameters

Parameter Type Description
name string The party identification name for the device user.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setPartyIdentificationName("Jane Doe");

See Also

setPartyIdentificationNumber

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

Syntax

SFMCSdkModule.setPartyIdentificationNumber(numberValue);

Parameters

Parameter Type Description
numberValue string The party identification number for the device user.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setPartyIdentificationNumber("PID-1001");

See Also

setPartyIdentificationType

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

Syntax

SFMCSdkModule.setPartyIdentificationType(type);

Parameters

Parameter Type Description
type string The party identification type for the device user.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setPartyIdentificationType("customer");

See Also

getPartyIdentificationName

Returns the party identification name currently set on the device.

Syntax

SFMCSdkModule.getPartyIdentificationName();

Returns

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

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const partyName = await sfmc.getPartyIdentificationName();

See Also

getPartyIdentificationNumber

Returns the party identification number currently set on the device.

Syntax

SFMCSdkModule.getPartyIdentificationNumber();

Returns

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

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const partyNumber = await sfmc.getPartyIdentificationNumber();

See Also

getPartyIdentificationType

Returns the party identification type currently set on the device.

Syntax

SFMCSdkModule.getPartyIdentificationType();

Returns

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

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const partyType = await sfmc.getPartyIdentificationType();

See Also

track

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

Syntax

SFMCSdkModule.track(event);

Parameters

Parameter Type Description
event object The SFMCEvent payload to track. Valid event types are CustomEvent, EngagementEvent, IdentityEvent, SystemEvent, CartEvent, OrderEvent, and CatalogObjectEvent.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi, SFMCEvent } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const event: SFMCEvent = { objType: "CustomEvent", name: "app_open" };
sfmc.track(event);

See Also

sendImmediate

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

Syntax

SFMCSdkModule.sendImmediate(event);

Parameters

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.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi, SFMCEvent } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const event: SFMCEvent = {
  objType: "CartEvent",
  subtype: "add",
  lineItems: [
    {
      catalogObjectType: "Product",
      catalogObjectId: "sku-1",
      quantity: 2,
      price: 9.99,
      currency: "USD",
    },
  ],
};
sfmc.sendImmediate(event);

See Also

flush

Flushes all queued events to Marketing Cloud servers immediately.

Syntax

SFMCSdkModule.flush();

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.flush();

See Also

setLogging

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

Syntax

SFMCSdkModule.setLogging(level);

Parameters

Parameter Type Description
level string The SDK log level. Valid values are DEBUG, WARN, ERROR, and NONE.

Returns

  • void

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
sfmc.setLogging("DEBUG");

See Also

getSdkState

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

Syntax

SFMCSdkModule.getSdkState();

Returns

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

Example

import { SFMCSdkModule } from "@sfmc/react-native-sfmc-core";
import type { SFMCSdkApi } from "@sfmc/react-native-sfmc-core";

const sfmc: SFMCSdkApi = await SFMCSdkModule.requestSdk();
const sdkState = await sfmc.getSdkState();

See Also