sfmc_push 1.1.0
sfmc_push: ^1.1.0 copied to clipboard
Flutter bridge for SFMC Push notifications (token, enable/disable)
SFMC Push #
SFMC Push Feature for Flutter — FCM/APNs registration, push enable/disable, and push token events.
Installation #
flutter pub add sfmc_push
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. - Configure Firebase (Android) and APNs (iOS) credentials before push will deliver.
Usage #
import 'package:sfmc_push/sfmc_push.dart';
// Initialize the Push module
await PushModule.requestSdk();
// Enable push notifications
await PushModule.enablePush();
// Check push state
final enabled = await PushModule.isPushEnabled();
// Get push token
final token = await PushModule.getPushToken();
// Subscribe to token refresh events
PushModule.pushTokenStream.listen((token) {
print('Token refreshed: $token');
});
API #
| Method | Return | Description |
|---|---|---|
requestSdk() |
Future<void> |
Initialize the Push SDK module |
enablePush() |
Future<void> |
Enable push notifications |
disablePush() |
Future<void> |
Disable push notifications |
isPushEnabled() |
Future<bool> |
Check if push is enabled |
getPushToken() |
Future<String?> |
Get the current device push token |
Streams #
| Stream | Type | Description |
|---|---|---|
pushTokenStream |
Stream<String?> |
Emits a new token whenever the push token changes (Android only) |
Notes #
Push registration requires Firebase configuration on Android (google-services.json in your app). On iOS, ensure the target has Push Notifications and Background Modes (Remote Notifications) capabilities enabled in your Apple Developer account.
Versions #
- Flutter: >=3.3.0
- Dart SDK: >=3.0.6 <4.0.0
- Android: pushfeaturemodule 2.0.+
- iOS: SFPushFeatureSDK ~> 2.0.0, MarketingCloud-SFMCSdk ~> 4.0.0
License #
BSD 3-Clause.