sfmc_iam 1.1.0
sfmc_iam: ^1.1.0 copied to clipboard
Flutter bridge for SFMC In-App Messaging
SFMC In-App Messaging #
SFMC In-App Messaging Feature for Flutter — lifecycle events, display control, and programmatic message display.
Installation #
flutter pub add sfmc_iam
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 #
Basic Setup #
import 'package:sfmc_iam/sfmc_iam.dart';
// Initialize the IAM module
await IamModule.requestSdk();
// Programmatically show an in-app message by ID
await IamModule.showInAppMessage('message-id');
Listen to Lifecycle Events #
// Listen to shouldShow, didShow, didClose events
IamModule.inAppMessageEvents.listen((event) {
print('IAM Event: ${event.type.name} for message ${event.message.id}');
if (event.type == InAppMessageEventType.didShow) {
// Message was shown
}
});
Control Message Display #
// Register a decision handler to control which messages display
await IamModule.setInAppMessageDecisionHandler((message) {
// Return true to show, false to suppress
final allowedIds = {'message-1', 'message-2'};
return allowedIds.contains(message.id);
});
// Clear the handler to restore default behavior (show all)
await IamModule.setInAppMessageDecisionHandler(null);
Customize Appearance #
// Set custom font (Android & iOS)
await IamModule.setInAppMessageFont('CustomFont-Regular');
// Set status bar color (Android only)
await IamModule.setStatusBarColor(0xFF000000); // Black
API #
| Method | Return | Description |
|---|---|---|
requestSdk() |
Future<void> |
Initialize the In-App Messaging SDK module |
showInAppMessage(id) |
Future<void> |
Programmatically display a message by ID |
inAppMessageEvents |
Stream<InAppMessageEvent> |
Stream of lifecycle events (shouldShow, didShow, didClose) |
setInAppMessageDecisionHandler(handler) |
Future<void> |
Register handler to control which messages display |
setInAppMessageFont(fontName) |
Future<void> |
Set custom font for messages (null = system default) |
setStatusBarColor(colorArgb) |
Future<void> |
Set status bar color (Android only) |
Notes #
- The plugin handles IAM lifecycle events via native delegates and bridges them to Dart
- Decision handler uses defer-then-show pattern (approved messages appear with slight delay)
- Without a decision handler, all messages display by default
- Status bar color is Android-only; iOS call is a no-op
Versions #
- Flutter: >=3.3.0
- Dart SDK: >=3.0.6 <4.0.0
- Android: inappmessagingfeaturemodule 1.0.+
- iOS: SFInAppMessagingFeatureSDK ~> 1.0.0, MarketingCloud-SFMCSdk ~> 4.0.0
License #
BSD 3-Clause.