sfmc_plugin 1.0.0 sfmc_plugin: ^1.0.0 copied to clipboard
Salesforce Marketing Cloud (SFMC) - MobilePush SDK for Flutter. Implement the MobilePush SDK for your iOS and Android applications in Flutter.
sfmc_plugin #
Salesforce Marketing Cloud (SFMC) - MobilePush SDK for Flutter.
Marketing Cloud MobilePush lets you create and send notifications to encourage use of your app.
This SFMC Flutter Plugin includes:
-
Push Notifications Create a message using one of the templates in Marketing Cloud MobilePush or the Push Notification template in Content Builder or Journey Builder.
-
In-App Messages In-app messages allow you to interact with your mobile app users while they use your mobile app, which is when they are most engaged. Trigger a message to show in your mobile app when a user opens the app on their device. While you can send this message to all of a contact’s devices, it only shows on the first device that opens the app. In-app messages can’t be created in MobilePush.
Learn more about SFMC Mobile Push SDK:
Install #
Add sfmc_plugin
to your pubspec.yaml
dependencies:
...
dependencies:
flutter:
sdk: flutter
sfmc_plugin:
...
Setup Android #
Create an app in MobilePush. This process connects the device to the MobilePush app you created previously in MobilePush.
Note: The Android SDK requires Android API 21 or greater and has dependencies on the Android Support v4 and Google Play Services libraries.
Prerequisites
- Implement the SDK
- Update module-level build.gradle file
Add the SDK repository:
repositories {
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
Add the SDK dependency:
dependencies {
implementation 'com.salesforce.marketingcloud:marketingcloudsdk:8.0.6'
}
- Set up Firebase Follow the Android Firebase setup documentation. When you add the Firebase core dependency to your module gradle file, use:
dependencies {
implementation platform('com.google.firebase:firebase-bom:30.3.0')
}
Note: Don't forget to add your Firebase google-services.json to your android/app folder and initialize Firebase in your Flutter project. Example:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isAndroid) {
await Firebase.initializeApp();
}
runApp(const MyApp());
}
Setup iOS #
Note: Please follow the Provision for Push and use the Flutter plugin.
Use Flutter Plugin #
The first step is initializing the SFMC plugin with credential information. Learn more
var isInitialized = await SfmcPlugin().initialize(
appId: '<YOUR_APP_ID>',
accessToken: '<YOUR_ACCESS_TOKEN>',
mid: '<YOUR_MID>',
sfmcURL:
'<YOUR_SFMC_URL>',
senderId: '<YOUR_FIREBASE_CLOUD_MESSAGING_SENDER_ID>',
locationEnabled: false,
inboxEnabled: false,
analyticsEnabled: true,
delayRegistration: true);
The second step is setting your sfmc contact key which is a unique client id in Salesforce Marketing Cloud.
await SfmcPlugin().setContactKey('<Uniquely Identifying Key>');
Contributions #
Feel free to contribute to this project.