This page will guide you to integrate and verify Contlo SDK in your Flutter application.
Prerequisites
To start the SDK integration, you must first create an API key and install the Mobile Push app from the Contlo App market. Go to your Contlo Dashboard and follow the steps below:
Create an API key
- Go to your profile section at the top right corner and click Settings.
- Go to Accounts > Store Settings from the sidebar on the Settings homepage.
- Go to the API keys tab on the Store Settings page and click Create key on the Private API keys section.
- Copy the newly created API key to add it later during the SDK integration.
Install Mobile push
- Go to App Market from the sidebar and search Mobile Push.
- Click Install.
Installation
To install the Contlo SDK in your Flutter project, follow the steps below:
- In your Flutter project, open the pubspec.yaml file and add the
contlo_plugin
underdependencies
:
dependencies:
contlo_plugin: ^1.0.0
- To fetch the Contlo package, save the changes made on pubspec.yaml file and run the follwing command in the terminal:
flutter pub get
- To use the Contlo SDK in your Flutter project, import the SDK in the respective dart file.
import 'package:contlo_plugin/contlo_plugin.dart';
Every method within the Contlo SDK is asynchronous, that means you must invoke them using the async and await keyword.
Initialization
Once the installation is complete, follow the steps below to initialize the Contlo SDK:
- Open the file that represents the start of the application (eg.
main.dart
) and import the Contlo package.
import 'package:contlo_plugin/contlo_plugin.dart';
- Add the Contlo's
init()
method after the your App's runApp() method.- Pass the API key (created from the Contlo dashboard) as the parameter in the
init()
method.
- Pass the API key (created from the Contlo dashboard) as the parameter in the
void main() {
runApp (const MyApp ()) ;
ContloPlugin.init("<Your API KEY>");
}
Verify Integration:
After initializing the SDK, open your application on a device or emulator.
Go to the Audiences section on your Contlo dashboard. You would see a new anonymous user is created.
You have successfully integrated the Contlo Flutter SDK.
Welcome aboard!