Overview
This guide provides step-by-step instructions to integrate the AppTrove Flutter SDK into your Flutter application, covering setup for both Android and iOS platforms. It includes adding the SDK, updating dependencies, and configuring necessary permissions and identifiers.
Prerequisites
- Flutter 2.0 or later
- Dart 2.12 or later
- Android API 21 (Android 5.0) or later
- iOS 10.0 or later
- Xcode 12.0 or later (for iOS)
- CocoaPods installed for iOS dependency management
- Gradle for Android dependency management
- A Trackier MMP account with an SDK key
- Access to your project's
pubspec.yaml
,AndroidManifest.xml
, andbuild.gradle
files
Installation
Step 1: Add AppTrove SDK to Your App
The AppTrove Flutter SDK can be added to your project in two ways.
Option 1: Update pubspec.yaml
Add the following dependency to your pubspec.yaml
file:
Find the latest version on pub.dev
dependencies:
trackier_sdk_flutter: ^1.6.65 // Use Latest Version
Option 2: Use CLI Command
Run the following command in your terminal:
flutter pub add trackier_sdk_flutter
This command automatically adds the SDK to your pubspec.yaml
.
Install Dependencies
Run the following command to update packages:
flutter pub get
Step 2: Update Pod Dependencies (iOS)
For iOS apps, ensure CocoaPods dependencies are installed.
Steps
- Navigate to the
ios
folder in your Flutter project:
cd ios
- Install dependencies:
pod install
- Open the generated
.xcworkspace
file in Xcode to build and run the iOS app.
Step 3: Add Android Install Referrer
The Android Install Referrer library is required to track app installs accurately.
Steps
Add the Install Referrer dependency to your android/app/build.gradle
file:
dependencies {
implementation 'com.android.installreferrer:installreferrer:2.2'
}
Check the latest version to ensure compatibility.
Step 4: Add Required Permissions (Android)
The AppTrove SDK requires specific permissions to function correctly on Android.
Steps
Add the following permissions to your android/app/src/main/AndroidManifest.xml
file if not already present:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Optional -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
Step 5: Enable Google Advertising ID (Android)
The AppTrove SDK requires the Google Advertising ID for accurate tracking.
Steps
- Add the Google Play Services Ads Identifier dependency to your
android/app/build.gradle
:
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
}
- Add the following permission to your
android/app/src/main/AndroidManifest.xml
(required for Android 12+):
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
- Add the Google Play Services version metadata inside the
<application>
tag:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Next Steps
After completing the installation:
- Initialize the AppTrove SDK in your app.
- Test your integration to ensure proper tracking of installs and events.
For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.