DeepLink - Flutter SDK

Install the Airbridge Flutter SDK and implement the necessary settings following the steps below.

Install SDK

The Airbridge Flutter SDK can be installed using the method below. After installation, you can verify whether the SDK has been properly installed through testing.

1. Add the following code to the dependencies block in the pubspec.yaml file.

12345
dependencies:
  # Replace $HERE_LATEST_VERSION with latest version
  # - Versions: https://pub.dev/packages/airbridge_flutter_sdk/versions
  # - Example: airbridge_flutter_sdk: 0.0.0
  airbridge_flutter_sdk: $HERE_LATEST_VERSION

2. Open Terminal at the root directory of the project and run the following command.

Note that the Airbridge Flutter SDK only works for Flutter versions 1.20.0 or later and Dart versions 2.12.0 or later.

Shell
1
flutter pub get

Install Restricted SDK

提示

请根据需求选择一般 SDK 或 Restricted SDK, 只能安装其中一个。

Depending on policies and environments, restrictions on collecting device IDs like GAID and IDFA may be required. When installing the Restricted SDK version, the device IDs are not collected.

Install the Restricted SDK using the method below.

1. Add the following code to the dependencies block in the pubspec.yaml file.

12345
dependencies:
  # Replace $HERE_LATEST_VERSION with latest version
  # - Versions: https://pub.dev/packages/airbridge_flutter_sdk/versions
  # - Example: airbridge_flutter_sdk: 0.0.0
  airbridge_flutter_sdk_restricted: $HERE_LATEST_VERSION

2. Open Terminal at the root directory of the project and run the following command.

Shell
1
flutter pub get

Initialize SDK

The initialization methods for iOS and Android are different. Refer to the methods described below.

Note that the YOUR_APP_NAME and YOUR_APP_SDK_TOKEN can be found on the [Settings]>[Tokens] page in the Airbridge dashboard.

iOS

Add the following code to the AppDelegate class file in the iOS module of the project.

12345678
import airbridge_flutter_sdk

override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    AirbridgeFlutter.initializeSDK(name: "YOUR_APP_NAME", token: "YOUR_APP_SDK_TOKEN")
}

Android

If an application class is not defined in the Android module of the project, create one.

Add the following code to the android/app/src/main/java/.../MainApplication.kt file.

123456789
import co.ab180.airbridge.flutter.AirbridgeFlutter
import android.app.Application

class MainApplication: Application() {
    override fun onCreate() {
        super.onCreate()
        AirbridgeFlutter.initializeSDK(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
    }
}

Register the application class created earlier in the AndroidManifest.xml file of the Android module of the project as follows.

12345
<application
    android:name=".MainApplication"
    ...>
    ...
</application>

Configure SDK settings

Configure the SDK settings to use the Airbridge Flutter SDK.

1234
{
    "autoDetermineTrackingAuthorizationTimeoutInSecond": number,
    "isHandleAirbridgeDeeplinkOnly" : boolean
}
  1. Create an airbridge.json file at the top level of the Flutter project folder, input the JSON as above, and configure the SDK settings.

  2. Don't input values for keys that are not necessary for your service.

For detailed guidance on the individual key values, refer to the links listed below.

Configure ATT prompt

提示

为确保遵守隐私政策所需的功能,应与法律顾问共同审查。

In the iOS environment, the IDFA can only be collected when users provide consent for data tracking through the App Tracking Transparency (ATT) prompt.

Event collection should be delayed until the user allows tracking. If the install event is collected before the user allows tracking through the ATT prompt, the install event data will lack an identifier, making performance measurement difficult. We recommend setting a sufficient delay time for event collection to collect identifiers.

1. Prepare the text you will use in the ATT prompt.

2. Provide the ATT prompt following this guide provided by Apple.

3. If the install event is not collected, the Airbridge Flutter SDK delays collecting install events for 30 seconds until the user allows tracking each time the app is launched. If the user exits the app before deciding whether to allow tracking, the SDK will not collect the install event and will try again at the next app launch.

In the SDK settings, configure autoDetermineTrackingAuthorizationTimeout to set a sufficient delay time for collecting install events. The default value is 30 seconds, and it can be set to up to 3600 seconds (1 hour).

提示

在 DeepLink Plan 中,建议将 setAutoDetermineTrackingAuthorizationTimeout 函数设为 0 秒。DeepLink Plan 不支持基于标识符的归因。为了使安装 App 的用户能立即通过 延迟深度链接 跳转至预设目标页面,建议将该函数设为 0 秒。

Deep Linking

Deep linking allows you to redirect users from ads to specific locations within your app. The data collected from the tracking link enables you to monitor the performance of the deep link in Airbridge.

When a user clicks on the Airbridge tracking link, the scheme deep link embedded in the tracking link is converted into an Airbridge Deep Link, which can be either an HTTP deep link or a scheme deep link. This Airbridge Deep Link redirects the user to the desired app location. Then, the Airbridge SDK converts the Airbridge Deep Link back to the original scheme deep link embedded in the tracking link and passes it to the app.

  • Example scheme deep link embedded in the tracking link: YOUR_SCHEME://product/12345

  • Examples of Airbridge Deep Links

    • HTTP deep link format 1: https://YOUR_APP_NAME.airbridge.io/~~~

    • HTTP deep link format 2: https://YOUR_APP_NAME.abr.ge/~~~

    • Scheme deep link format: YOUR_SCHEME://product/12345?airbridge_referrer=~~~

When the app is installed on the device and the tracking link is clicked, the app opens through the Airbridge Deep Link. The Airbridge SDK converts the Airbridge Deep Link into the scheme deep embedded in the tracking link and passes it to the app.

When the app is not installed on the device and the tracking link is clicked, the Airbridge SDK saves the Airbridge Deep Link. After the user is redirected to the app store or website and the app is installed and launched, the Airbridge SDK converts the saved Airbridge Deep Link into the scheme deep link embedded in the tracking link and passes it to the app.

Set up deep linking

For the deep linking setup, the deep link information entered to the Airbridge dashboard and the in-app location address for user redirection is required.

First, enter the deep link information into the Airbridge dashboard.

After entering the deep link information into the Airbridge dashboard, an additional setup is required to enable the following.

  • App launch with Airbridge deep links

  • Airbridge deep link event collection

  • User redirection with Airbridge deep links

For detailed instructions, refer to the information below.

Set up deferred deep linking

When a user clicks on a tracking link with deferred deep linking capabilities and your app is not installed on the device, the Airbridge SDK retrieves the deep link as follows.

Deferred deep links are automatically passed to OnDeeplinkReceived, so no additional setup is required.

Testing

The SDK functionality test and deep link test allow you to check whether the SDK and deep linking work as intended.

Additional SDK Settings

Follow the instructions below for additional setup.

提示

此功能并非必需功能,请在设置前确认需求。

提示

Airbridge Flutter SDK 需为 v4.1.2 或以上版本。

The deep links passed through the setOnDeeplinkReceived method of the Airbridge Flutter SDK include not only Airbridge Deep Links but also deep links from other solutions.

12345
import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
...
Airbridge.setOnDeeplinkReceived((url) {
    // show proper content using url
});

By configuring isHandleAirbridgeDeeplinkOnly to true in the SDK settings, only Airbridge Deep Links will be passed to the setOnDeeplinkReceived callback. In this way, you can handle the deep links from other solutions separately from the Airbridge Deep Links.

Was this helpful?

Any questions or suggestions?