The Rokt Flutter SDK enables you to integrate Rokt into your native mobile apps to drive more value from—and for—your customers.
The Rokt SDK for Flutter applications can be used by Rokt partners to display overlay or embedded placements, or by Rokt advertisers to record conversions for campaigns.
- Danial Motahari - [email protected]
- Sahil Suri - [email protected]
Environment | Build |
---|---|
release |
To use this plugin, add following code in your pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
rokt_sdk: ^4.0.0-alpha.3
- Set the minSdkVersion and enable multidex in
android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 21
multidexEnabled true
}
}
This means that app will only be available for users that run Android SDK 21 or higher.
-
Include appcompat dependency
implementation 'androidx.appcompat:appcompat:x.x.x’
The theme of android/app should extend from AppCompat Theme family, example:<style name="NormalTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"/>
Rokt iOS SDK supports iOS version 10 and above
_ Run flutter clean
- Delete /ios/Pods
- Delete /ios/Podfile.lock
- Run
flutter pub get
- From inside ios folder, run
pod install
Initialize the Rokt SDK prior to using it. We recommend calling the initialize method in the beginning of the applications.
// The following will reveal a demo integration. To view your integration:
// 1) Replace the integration test tag ID (222) with your unique Rokt Tag ID
// 2) Replace 1.0.0 with the application version
RoktSdk.initialize('222', appVersion: '1.0.0');
Execute the Rokt iOS SDK in your desired view and add all appropriate customer attributes. The SDK provides optional callback events for when the view loads and unloads.
import 'package:rokt_sdk/rokt_sdk.dart';
void executeRokt() {
// Replace RoktExperience with your viewName
RoktSdk.execute(
viewName: "RoktExperience",
attributes: {"email": "[email protected]",
"firstname": "Jenny",
"lastname": "Smith",
"mobile": "(555)867-5309",
"postcode": "90210",
"country": "US"},
config: RoktConfig(), // Optional RoktConfig object
onLoad: () {
// Optional callback for when the Rokt placement loads
},
onUnLoad: () {
// Optional callback for when the Rokt placement unloads
},
onShouldShowLoadingIndicator: () {
// Optional callback to show a loading indicator
},
onShouldHideLoadingIndicator: () {
// Optional callback to hide a loading indicator
});
}
To run an placement in the sandbox environment, the list of attributes passed to Rokt needs to be updated to include "sandbox": "true"
add const RoktWidget(placeholderName: "RoktEmbedded1")
in your view.
please make sure that the view is created on the visible area of the screen and then call showWidget.
RoktWidget has a callback to notify when widget is created which could be utilized.
RoktWidget(placeholderName: "RoktEmbedded1", onWidgetCreated: () { showWidget() })
import 'package:rokt_sdk/rokt_sdk.dart';
void showWidget() {
// Replace RoktExperience with your viewName
RoktSdk.execute(
viewName: "RoktExperience",
attributes: {"email": "[email protected]",
"firstname": "Jenny",
"lastname": "Smith",
"mobile": "(555)867-5309",
"postcode": "90210",
"country": "US"},
config: RoktConfig(), // Optional RoktConfig object
onLoad: () {
// Optional callback for when the Rokt placement loads
},
onUnLoad: () {
// Optional callback for when the Rokt placement unloads
},
onShouldShowLoadingIndicator: () {
// Optional callback to show a loading indicator
},
onShouldHideLoadingIndicator: () {
// Optional callback to hide a loading indicator
});
}
To run an placement in the sandbox environment, the list of attributes passed to Rokt needs to be updated to include "sandbox": "true"
Download Android Studio or VS Code for editor and install Flutter SDK
Requirements to integrate from versions 4.0.0 onwards include:
- Kotlin version 1.8.0 or newer (e.g.
ext.kotlin_version = '1.8.0'
) - Android Gradle plugin 7.4.0 or newer (e.g.
com.android.tools.build:gradle:7.4.0
) - Gradle version 7.5 or newer (e.g.
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
)
This project consists of sdk Plugin which contains lib which is the main entry for the sdk plugin, android, iOS platform specific code for the sdk plugin and an example App which is a sample App to run the sdk plugin.
This SDK is published to pub.dev here. You can publish the alpha or prod package.
To publish the package, you need to modify pubspec.yaml and update the version field. We should append -alpha
after version if we intend to publish
the alpha package. Make sure you add the changes in CHANGELOG.md.
Publishing the package is possible through CircleCi or Buildkite by approving the hold_for_publish
job.
- Make sure you have following environment variables set:
PUB_DEV_PUBLISH_ACCESS_TOKEN= PUB_DEV_PUBLISH_REFRESH_TOKEN= PUB_DEV_PUBLISH_TOKEN_ENDPOINT= PUB_DEV_PUBLISH_EXPIRATION=
- Run following command
cd .circleci ./pub_login.sh dart pub publish -f
The SDK can be released via the Mobile Release Pipeline. Follow the instructions in the Mobile Release Pipeline repo to release. You can still release the SDK manually by following the steps in the previous section.
UI test are located inside example app and you can run it by executing below command
flutter test integration_test/app_test.dart
- Open project in Android Studio for changing the code
- Run following commands in terminal or equivalent in Android Studio
- Run
flutter clean
- Run
flutter pub get
- Run
flutter run
There is one main branch with release- prefix. This branch is where all development branches are merged into. Publishing the package is possible with release- prefix branches only.
To update the iOS rokt sdk, make the following changes.
s.version = 'X.X.X'
s.dependency 'Rokt-Widget', '~> X.X.X'
For Android, do the folliwing
implementation "com.rokt:roktsdk:X.X.X"
Copyright 2020 Rokt Pte Ltd
Licensed under the Rokt Software Development Kit (SDK) Terms of Use Version 2.0 (the "License");
You may not use this file except in compliance with the License.