Skip to main content

Flutter SDK Setup

BETA

The plugin is fully functional and integrates with our AppLink service, which is currently in public beta. While you can start using it today, please note that there may be minor changes or improvements as we prepare for full production launch.

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

apiKey Setup
  • Make sure to configure the API key properly. For additional information Getting started
Prerequisites

iOS Requirements and Setup

Requirements​

  • iOS deployment target: 13.0

  • Provide your application id in your app info.plist file.

  • Add Associated Domain.

Note
  • Configuring associated domains is optional.
  • In Xcode, Under TARGETS, select your app target (usually the one named after your app).
  • At the top, select the Signing & Capabilities tab.
  • Click the + Capability button in the top-left corner of that section.
  • In the list of capabilities, scroll or search to select Associated Domains.
  • This will automatically create a file named YOUR_PROJECT.entitlements.

Associated Domains

YOUR_APP.entitlements
<!-- If Using Universal Links -->
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:YOUR_DOMAIN</string> <!-- Replace with your actual domain -->
</array>
Note

After configuring the Associated Domain for Universal Links, it may take up to 24 hours for the changes to be reflected and become active. The Associated Domain setup and verification process is managed by Apple.

  • Add Custom URL scheme
info.plist
<!-- If Using Custom Url Schema -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>YOUR_URL_NAME</string>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_CUSTOM_URL_SCHEME</string> <!-- Replace with your custom URL scheme -->
</array>
</dict>
</array>

Android Requirements and Setup

Requirements​

  • Android Gradle Plugin (AGP): Version 8.0.2 or higher
  • Kotlin: Version 1.7.10 or higher
  • Gradle: Version 8.0 or higher

Setup

Add the following code to settings.gradle

setting.gradle
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://jitpack.io' }
}
}

Add below code to your root level build.gradle

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

Add Required Code

Add below code to the app's AndroidManifest.xml file under the activity tag of your main activity.

AndroidManifest.xml
 <intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="your domain"
android:scheme="https" />
</intent-filter>

Add below code if you are using custom uri scheme.

AndroidManifest.xml
 <intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="open"
android:scheme="your scheme" />
</intent-filter>

Use of Package

 $ flutter pub add appsonair_flutter_applink

Import it

Now in your Dart code, you can use:

Import
import 'package:appsonair_flutter_applink/appsonair_flutter_applink.dart';
Initialization

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

for IOS

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

Package use

@override
void initState() {
final _appsonairFlutterApplinkPlugin = AppsonairFlutterApplink();
_appsonairFlutterApplinkPlugin.initializeAppLink().listen((appLink) {
if (appLink != null) {
// Handle the AppLink when it is received
"AppLink Received: ${appLink.toString()}".printLog();
// You can navigate to a specific screen or perform an action based on the AppLink
}
});
super.initState();
}
  • To initializeAppLink() is use for initialize the common AppLink service and handling the link when app is launched with link.
Package use

@override
void initState() {
final _appsonairFlutterApplinkPlugin = AppsonairFlutterApplink();
_appsonairFlutterApplinkPlugin.createAppLink(
appLinkParams: AppLinkParams(
url: "deepLinkUrl",
name: "linkName",
urlPrefix: "urlPrefix", //Your Domain name and shouldn't contain http or https
androidFallbackUrl: "fallback URL", //Android fallback URL
iOSFallbackUrl: "fallback URL", //IOS fallback URL
shortId: "linkShortId", // Link shortId
socialMeta: SocialMeta(description: "description", imageUrl: "imageUrl", title: "title"),
));
super.initState();
}

AppLinkParams Properties

Defines all parameters used to construct a AppLink, including app URL, fallbacks, short ID, and social-meta.

KeyDescription
urlThe actual deep link URL that the app should open. Example: myapp://product/123
nameThe name or label for the link, often used for internal identification.
urlPrefixThe base URL prefix for the link (e.g., https://app.domain.com/). This helps create a complete shareable link.
androidFallbackUrlA web URL to redirect users to when the app is not installed on Android devices.
iOSFallbackUrlA web URL to redirect users to when the app is not installed on iOS devices.
shortIdAn optional short ID to make the link shorter and easier to share. If provided, the final link becomes urlPrefix/shortId
socialMetaMeta information used for social sharing previews. refer SocialMeta Properties
isOpenInBrowserAppleDetermines whether the link should open in the browser on Apple devices (iOS/macOS).
isOpenInIosAppSpecifies if the link should open in the iOS app even if your app is installed.
isOpenInAndroidAppIndicates whether to open the link in the Android app even if your app is installed.
isOpenInBrowserAndroidDetermines if the link should open in the browser on Android devices.

socialMeta Properties

KeyDescription
titleThe title to show in social media link previews.
descriptionA short description used in social sharing cards (Facebook, Twitter, etc.).
imageUrlA URL to an image that will appear in the social media preview.
Package use

@override
void initState() {
var data = await _appsonairFlutterApplinkPlugin.getReferralDetails();
// handling data according the referral information
super.initState();
}
  • To getReferralDetails() is used for get the latest referral information.
Response
{
"data": {
"shortId": "linkId",
"referralLink": "https://your.referral.link"
}
}
note

For testing purposes in IOS:

  • Click the referral link, it should redirect you to the App Store.
  • To retrieve the latest referral data, you must uninstall the app, then reinstall it, and fetch the referral again.

Run your app by using code editor on Android/IOS simulators or any physical device to make sure it builds correctly.

For more details explore the example