Flutter SDK Setup
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
- Make sure to configure the API key properly. For additional information Getting started
- Before getting started, ensure your AppLink Configuration is set up.
iOS Requirements and Setup
Requirements
-
iOS deployment target: 13.0
-
Provide your application id in your app info.plist file.
-
Add Associated Domain.
- 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
.
<!-- If Using Universal Links -->
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:YOUR_DOMAIN</string> <!-- Replace with your actual domain -->
</array>
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
<!-- 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
- Groovy
- Kotlin
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://jitpack.io' }
}
}
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven("https://jitpack.io")
}
}
Add below code to your root level build.gradle
- Groovy
- Kotlin
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
Add Required Code
Add below code to the app's AndroidManifest.xml
file under the activity tag of your main activity.
<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.
<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>
Add the AppLink Service in Flutter Code and Usage
Use of Package
- Dart
$ flutter pub add appsonair_flutter_applink
Import it
Now in your Dart code, you can use:
- Dart
import 'package:appsonair_flutter_applink/appsonair_flutter_applink.dart';
Call the Service in initState and Handle the AppLink as Required
Make sure that to call initializeAppLink()
method after MaterialApp!
Don't forgot to install pods! (for iOS)
- Dart
@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.
Call the Service to Create an AppLink
- Dart
@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.
Key | Description |
---|---|
url | The actual deep link URL that the app should open. Example: myapp://product/123 |
name | The name or label for the link, often used for internal identification. |
urlPrefix | The base URL prefix for the link (e.g., https://app.domain.com/) . This helps create a complete shareable link. |
androidFallbackUrl | A web URL to redirect users to when the app is not installed on Android devices. |
iOSFallbackUrl | A web URL to redirect users to when the app is not installed on iOS devices. |
shortId | An optional short ID to make the link shorter and easier to share. If provided, the final link becomes urlPrefix/shortId |
socialMeta | Meta information used for social sharing previews. refer SocialMeta Properties |
isOpenInBrowserApple | Determines whether the link should open in the browser on Apple devices (iOS/macOS). |
isOpenInIosApp | Specifies if the link should open in the iOS app even if your app is installed. |
isOpenInAndroidApp | Indicates whether to open the link in the Android app even if your app is installed. |
isOpenInBrowserAndroid | Determines if the link should open in the browser on Android devices. |
socialMeta Properties
Key | Description |
---|---|
title | The title to show in social media link previews. |
description | A short description used in social sharing cards (Facebook, Twitter, etc.). |
imageUrl | A URL to an image that will appear in the social media preview. |
Call the Service to Retrieve the Referral Link
- Dart
@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.
- Android
- iOS
{
"data": {
"shortId": "linkId",
"referralLink": "https://your.referral.link"
}
}
{
"message": "Referral link fetched successfully!",
"status": "SUCCESS",
"data": {
"link": "https://your.link",
"name": "AppLink",
"referralLink": "https://your.referral.link",
"shortId": "linkId",
"socialMetaTags": {
"description": "Description",
"imageUrl": "https://example.xom",
"title": "Meta Title"
}
}
}
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 and Set Up Your AppLink Services
Run your app by using code editor on Android/IOS simulators or any physical device to make sure it builds correctly.