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
SFMCSdkModule.setProfileId(profileId);
Parameters
| Parameter | Type | Description |
|---|---|---|
profileId |
String |
The value to set as the profile ID of the device's user. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setProfileId('user-1234');
See Also
getProfileId
Returns the profile identifier for the device.
Syntax
SFMCSdkModule.getProfileId();
Returns
Future<String?>- A future that completes with the current profile ID.
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
final profileId = await SFMCSdkModule.getProfileId();
See Also
setAttribute
Sets the value of an attribute in the identity.
Syntax
SFMCSdkModule.setAttribute(key, value);
Parameters
| Parameter | Type | Description |
|---|---|---|
key |
String |
The name of the attribute to set. |
value |
String |
The value of the attribute to set. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setAttribute('email', 'sample@example.com');
See Also
clearAttribute
Clears the value of an attribute in the identity.
Syntax
SFMCSdkModule.clearAttribute(key);
Parameters
| Parameter | Type | Description |
|---|---|---|
key |
String |
The name of the attribute to clear the value of. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.clearAttribute('email');
See Also
setAttributes
Sets multiple attributes in the identity in one call.
Syntax
SFMCSdkModule.setAttributes(attributes);
Parameters
| Parameter | Type | Description |
|---|---|---|
attributes |
Map<String, String> |
A map of key-value pairs to set. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setAttributes({
'email': 'sample@example.com',
'tier': 'gold',
});
See Also
getAttributes
Returns a map of attributes for the identity.
Syntax
SFMCSdkModule.getAttributes();
Returns
Future<Map<String, String>?>- A future that completes with the current attribute map.
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
final attributes = await SFMCSdkModule.getAttributes();
See Also
clearAllAttributes
Clears all attributes from the identity.
Syntax
SFMCSdkModule.clearAllAttributes();
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.clearAllAttributes();
See Also
getPartyIdentificationName
Returns the party identification name currently for the device.
Syntax
SFMCSdkModule.getPartyIdentificationName();
Returns
Future<String?>- A future that completes with the current party identification name.
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
final partyName = await SFMCSdkModule.getPartyIdentificationName();
See Also
setPartyIdentificationName
Sets the party identification name for the device's user.
Syntax
SFMCSdkModule.setPartyIdentificationName(name);
Parameters
| Parameter | Type | Description |
|---|---|---|
name |
String |
The display name or full name of the user. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setPartyIdentificationName('Jane Doe');
See Also
getPartyIdentificationNumber
Returns the party identification number of the device.
Syntax
SFMCSdkModule.getPartyIdentificationNumber();
Returns
Future<String?>- A future that completes with the current party identification number.
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
final partyNumber = await SFMCSdkModule.getPartyIdentificationNumber();
See Also
setPartyIdentificationNumber
Sets the party identification number for the device's user.
Syntax
SFMCSdkModule.setPartyIdentificationNumber(number);
Parameters
| Parameter | Type | Description |
|---|---|---|
number |
String |
A unique identifier number for the user. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setPartyIdentificationNumber('PID-1001');
See Also
getPartyIdentificationType
Returns the party identification type currently set on the device.
Syntax
SFMCSdkModule.getPartyIdentificationType();
Returns
Future<String?>- A future that completes with the current party identification type.
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
final partyType = await SFMCSdkModule.getPartyIdentificationType();
See Also
setPartyIdentificationType
Sets the party identification type for the device's user.
Syntax
SFMCSdkModule.setPartyIdentificationType(type);
Parameters
| Parameter | Type | Description |
|---|---|---|
type |
String |
The category or classification for the user. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setPartyIdentificationType('customer');
See Also
track
Tracks an event, which could result in actions such as an in-app message being displayed.
Syntax
SFMCSdkModule.track(event);
Parameters
| Parameter | Type | Description |
|---|---|---|
event |
SFMCEvent |
An SFMCEvent instance to track, such as CustomEvent or CartEvent. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await 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
SFMCSdkModule.sendImmediate(event);
Parameters
| Parameter | Type | Description |
|---|---|---|
event |
SFMCEvent |
An SFMCEvent instance to send immediately, such as CustomEvent or CartEvent. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.sendImmediate(CustomEvent(name: 'purchase', attributes: {'item': 'shoes'}));
See Also
flush
Flushes all queued events to the Marketing Cloud servers immediately.
Syntax
SFMCSdkModule.flush();
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.flush();
See Also
setLogging
Sets the log level for the native Marketing Cloud SDK.
Syntax
SFMCSdkModule.setLogging(level);
Parameters
| Parameter | Type | Description |
|---|---|---|
level |
LogLevel |
The SDK log level. Valid values are LogLevel.debug, LogLevel.warn, LogLevel.error, and LogLevel.none. |
Returns
Future<void>
Example
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
await SFMCSdkModule.setLogging(LogLevel.debug);
See Also
getSdkState
Returns the SDK state for diagnostics.
Syntax
SFMCSdkModule.getSdkState();
Returns
Future<dynamic>- A future that completes with the state of the SDK. The state is usually returned as aMap<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
import 'package:sfmc_core/sfmc_core.dart';
await SFMCSdkModule.requestSdk();
final state = await SFMCSdkModule.getSdkState();