Skip to main content

Flutter SDK Setup

To integrate AppsOnAir Flutter SDK to your Flutter Apps, follow the below steps

1. Basic Requirements for service usage

i) iOS Requirements​

  • We are supporting iOS 10+ or iPadOS(iPhone, iPad, iPod Touch) to test on
  • A Mac with Xcode 13+

ii) Android Requirements​

- JAVA 11 required
- An Android 5.0+ device or emulator.
- Project using AndroidX.
- compileSDKVersion set to 30 or higher.
- Targets API level 21 (LOLLIPOP) or higher
- Gradle version 7.0+
- Requires Gradle version `7.0+`
- Uses Jetpack (AndroidX), which includes meeting these version requirements:
- `compileSdkVersion` 29 or later
  • Set up a physical device or use an emulator to run your app.
  • Create or login to your AppsOnAir (AoA) Account
  • Goto the your app details page -> App services tab -? API key tab to get your AoA services API Key

2. Add AppsOnAir Gradle Plugin and SDK

Newer versions of Android Studio

When creating a new project from Android Studio Artic Fox (or newer) the allprojects{...} is no longer added in the project level gradle.so need add in settings.gradle

gradle.properties
android.useAndroidX=true
android.enableJetifier=true

2.1 open your root build.gradle file, add the following

build.gradle

buildscript {
repositories {
...
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
build.gradle

allprojects {
repositories {
...
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

3. Add required code

Add meta-data to the app module's AndroidManifest.xml file under the application tag

AndroidManifest.xml
    <!-- add meta-data inside application tag -->
<application>
<!-- App icon for dialog -->
<meta-data
android:name="com.appsonair.icon"
android:resource="@drawable/app_icon" />

<!-- App name for dialog -->
<meta-data
android:name="com.appsonair.name"
android:value="app_name" />
</application>

Create string.xml file in to android/app/resourse/value and add below code.

string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name"> YOUR_APP_NAME </string>
</resources>

Applicaton icon

Also make sure to add app icon into drawable as app_icon

appimage

4. Add the AppsonAir Initialization code and usage

Use of package

pubspec.yaml
 $ flutter pub add appsonair_flutter_sdk

Import it:

Now in your Dart code, you can use:

Import
import 'package:appsonair_flutter_sdk/apps_on_air_service.dart';

First initialize AppsOnAir by using below code

Package use

// set showNativeUI = 'true' to show default native UI
void main() async {
AppsOnAir.setAppId('*********-e640-477c-aa48-***********',
showNativeUI: true);
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}

After inialized add below code, After MaterialApp initialization

You can call checkForAppUpdate() at your preference however, we recommend that, call checkForAppUpdate() in initState method as follows:

Package use

AppsOnAir.checkForAppUpdate(context);

Initialization

Make sure that to call checkForAppUpdate() method after MaterialApp!

for IOS

Don't forgot to install pods! (for iOS)

5. Set Custom UI (Optional step)

If you want to show a custom alert for app updates then set showNativeUI = false in setAppId() method. Now, call checkForAppUpdate method and pass custom widget to show a custom alert for app updates. To use this method where needed, use the same import statement as in the previous step. Use this method as follows:

With custom ui

AppsOnAir.checkForAppUpdate(
context,
customWidget: (response) {
///return your widget here
return Container();
},
);