sfmc_core 1.1.0
sfmc_core: ^1.1.0 copied to clipboard
Flutter bridge for SFMC Core SDK (identity, events, logging, state)
SFMC Core #
Unified SFMC SDK core for Flutter — identity, attributes, custom events, logging.
Installation #
flutter pub add sfmc_core
iOS:
cd ios && pod install
Android: no additional steps — Gradle resolves the dependency automatically.
Required SDK configuration #
- Android — initialize in your
MainApplication.ktviaSFMCSdk.configure(...). See the Android SDK Integration Guide. - iOS — initialize in your
AppDelegate.swiftviaSFMCSdk.initializeSdk(...). See the iOS SDK Integration Guide.
Usage #
import 'package:sfmc_core/sfmc_core.dart';
// Initialize the SDK
await SFMCSdkModule.requestSdk();
// Identity
await SFMCSdkModule.setProfileId('user-1234');
final profileId = await SFMCSdkModule.getProfileId();
// Attributes
await SFMCSdkModule.setAttribute('email', 'sample@example.com');
await SFMCSdkModule.setAttributes({'first_name': 'Jane', 'last_name': 'Doe'});
final attrs = await SFMCSdkModule.getAttributes();
// Custom event
await SFMCSdkModule.track(
CustomEvent(name: 'app_open', attributes: {'screen': 'home'}),
);
// Cart event
await SFMCSdkModule.track(
AddToCartEvent(
lineItem: LineItem(
catalogObjectType: 'Product',
catalogObjectId: 'sku-1',
quantity: 2,
price: 9.99,
currency: 'USD',
),
),
);
API #
| Method | Return | Description |
|---|---|---|
requestSdk() |
Future<void> |
Initialize the SFMC Core SDK |
setProfileId(id) |
Future<void> |
Set profile/contact key |
getProfileId() |
Future<String?> |
Get current profile ID |
setAttribute(key, value) |
Future<void> |
Set a single attribute |
setAttributes(attrs) |
Future<void> |
Set multiple attributes at once |
clearAttribute(key) |
Future<void> |
Remove an attribute |
clearAllAttributes() |
Future<void> |
Remove all attributes |
getAttributes() |
Future<Map<String, String>?> |
Get all attributes |
setPartyIdentificationName(name) |
Future<void> |
Set party identification name |
setPartyIdentificationNumber(num) |
Future<void> |
Set party identification number |
setPartyIdentificationType(type) |
Future<void> |
Set party identification type |
getPartyIdentificationName() |
Future<String?> |
Get party identification name |
getPartyIdentificationNumber() |
Future<String?> |
Get party identification number |
getPartyIdentificationType() |
Future<String?> |
Get party identification type |
track(SFMCEvent) |
Future<void> |
Track a structured event |
sendImmediate(SFMCEvent) |
Future<void> |
Send event immediately (bypasses batching) |
flush() |
Future<void> |
Flush pending analytics (60s throttle) |
setLogging(LogLevel) |
Future<void> |
Set log level: LogLevel.debug, LogLevel.warn, LogLevel.error, LogLevel.none |
getSdkState() |
Future<dynamic> |
Get full SDK state (a Map, or raw JSON String if the SDK emits non-strict JSON) |
Notes #
sfmc_core is the dependency root for every SFMC Flutter plugin. Other packages depend on it transitively — installing a product package (sfmc_marketingcloudsdk or sfmc_mobileappmessaging) auto-resolves this.
Versions #
- Flutter: >=3.3.0
- Dart SDK: >=3.0.6 <4.0.0
- Android: sfmcsdk 3.1.+
- iOS: MarketingCloud-SFMCSdk ~> 4.0.0
License #
BSD 3-Clause.