SFMC Core

This section provides API reference details for the SFMC Core module in the Flutter unified plugin.

setProfileId 

Sets the profile identifier for the device’s user.

Syntax 

1SFMCSdkModule.setProfileId(profileId);

Parameters 

ParameterTypeDescription
profileIdStringThe value to set as the profile ID of the device’s user.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setProfileId('user-1234');

See Also 

getProfileId 

Returns the profile identifier for the device.

Syntax 

1SFMCSdkModule.getProfileId();

Returns 

  • Future<String?> - A future that completes with the current profile ID.

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4final profileId = await SFMCSdkModule.getProfileId();

See Also 

setAttribute 

Sets the value of an attribute in the identity.

Syntax 

1SFMCSdkModule.setAttribute(key, value);

Parameters 

ParameterTypeDescription
keyStringThe name of the attribute to set.
valueStringThe value of the attribute to set.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setAttribute('email', 'sample@example.com');

See Also 

clearAttribute 

Clears the value of an attribute in the identity.

Syntax 

1SFMCSdkModule.clearAttribute(key);

Parameters 

ParameterTypeDescription
keyStringThe name of the attribute to clear the value of.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.clearAttribute('email');

See Also 

setAttributes 

Sets multiple attributes in the identity in one call.

Syntax 

1SFMCSdkModule.setAttributes(attributes);

Parameters 

ParameterTypeDescription
attributesMap<String, String>A map of key-value pairs to set.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setAttributes({
5  'email': 'sample@example.com',
6  'tier': 'gold',
7});

See Also 

getAttributes 

Returns a map of attributes for the identity.

Syntax 

1SFMCSdkModule.getAttributes();

Returns 

  • Future<Map<String, String>?> - A future that completes with the current attribute map.

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4final attributes = await SFMCSdkModule.getAttributes();

See Also 

clearAllAttributes 

Clears all attributes from the identity.

Syntax 

1SFMCSdkModule.clearAllAttributes();

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.clearAllAttributes();

See Also 

getPartyIdentificationName 

Returns the party identification name currently for the device.

Syntax 

1SFMCSdkModule.getPartyIdentificationName();

Returns 

  • Future<String?> - A future that completes with the current party identification name.

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4final partyName = await SFMCSdkModule.getPartyIdentificationName();

See Also 

setPartyIdentificationName 

Sets the party identification name for the device’s user.

Syntax 

1SFMCSdkModule.setPartyIdentificationName(name);

Parameters 

ParameterTypeDescription
nameStringThe display name or full name of the user.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setPartyIdentificationName('Jane Doe');

See Also 

getPartyIdentificationNumber 

Returns the party identification number of the device.

Syntax 

1SFMCSdkModule.getPartyIdentificationNumber();

Returns 

  • Future<String?> - A future that completes with the current party identification number.

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4final partyNumber = await SFMCSdkModule.getPartyIdentificationNumber();

See Also 

setPartyIdentificationNumber 

Sets the party identification number for the device’s user.

Syntax 

1SFMCSdkModule.setPartyIdentificationNumber(number);

Parameters 

ParameterTypeDescription
numberStringA unique identifier number for the user.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setPartyIdentificationNumber('PID-1001');

See Also 

getPartyIdentificationType 

Returns the party identification type currently set on the device.

Syntax 

1SFMCSdkModule.getPartyIdentificationType();

Returns 

  • Future<String?> - A future that completes with the current party identification type.

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4final partyType = await SFMCSdkModule.getPartyIdentificationType();

See Also 

setPartyIdentificationType 

Sets the party identification type for the device’s user.

Syntax 

1SFMCSdkModule.setPartyIdentificationType(type);

Parameters 

ParameterTypeDescription
typeStringThe category or classification for the user.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setPartyIdentificationType('customer');

See Also 

track 

Tracks an event, which could result in actions such as an in-app message being displayed.

Syntax 

1SFMCSdkModule.track(event);

Parameters 

ParameterTypeDescription
eventSFMCEventAn SFMCEvent instance to track, such as CustomEvent or CartEvent.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.track(CustomEvent(name: 'purchase', attributes: {'item': 'shoes'}));

See Also 

sendImmediate 

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

Syntax 

1SFMCSdkModule.sendImmediate(event);

Parameters 

ParameterTypeDescription
eventSFMCEventAn SFMCEvent instance to send immediately, such as CustomEvent or CartEvent.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.sendImmediate(CustomEvent(name: 'purchase', attributes: {'item': 'shoes'}));

See Also 

flush 

Flushes all queued events to the Marketing Cloud servers immediately.

Syntax 

1SFMCSdkModule.flush();

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.flush();

See Also 

setLogging 

Sets the log level for the native Marketing Cloud SDK.

Syntax 

1SFMCSdkModule.setLogging(level);

Parameters 

ParameterTypeDescription
levelLogLevelThe SDK log level. Valid values are LogLevel.debug, LogLevel.warn, LogLevel.error, and LogLevel.none.

Returns 

  • Future<void>

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4await SFMCSdkModule.setLogging(LogLevel.debug);

See Also 

getSdkState 

Returns the SDK state for diagnostics.

Syntax 

1SFMCSdkModule.getSdkState();

Returns 

  • Future<dynamic> - A future that completes with the state of the SDK. The state is usually returned as a Map<dynamic, dynamic> object, but the native SDK can emit non-strict JSON that fails to parse. In this situation, the SDK returns the raw JSON string instead. Parse the result in a way that can handle both object types.

Example 

1import 'package:sfmc_core/sfmc_core.dart';
2
3await SFMCSdkModule.requestSdk();
4final state = await SFMCSdkModule.getSdkState();

See Also