Install the Airbridge Flutter SDK and implement the necessary settings following the steps below.
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.
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.
flutter pub get
提示
请根据需求选择一般 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.
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.
flutter pub get
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.
Add the following code to the AppDelegat
e class file in the iOS module of the project.
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")
}
#import <airbridge_flutter_sdk/AirbridgeFlutter.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AirbridgeFlutter initializeSDKWithName:@"YOUR_APP_NAME" token:@"YOUR_APP_SDK_TOKEN"];
}
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.
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")
}
}
import co.ab180.airbridge.flutter.AirbridgeFlutter;
import android.app.Application;
public class MainApplication extends Application {
@Override
public void 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.
<application
android:name=".MainApplication"
...>
...
</application>
Configure the SDK settings to use the Airbridge Flutter SDK.
{
"autoDetermineTrackingAuthorizationTimeoutInSecond": number,
"isHandleAirbridgeDeeplinkOnly" : boolean
}
Create an airbridge.json file at the top level of the Flutter project folder, input the JSON as above, and configure the SDK settings.
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.
配置值 | 指南 |
---|---|
autoDetermineTrackingAuthorizationTimeoutInSecond | |
isHandleAirbridgeDeeplinkOnly |
提示
为确保遵守隐私政策所需的功能,应与法律顾问共同审查。
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 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.
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.
iOS 环境所需的深度链接信息如下:
iOS URI Scheme:根据 iOS URI Scheme,将 Airbridge 深度链接转换为 URI Scheme 深度链接。URI Scheme 深度链接需要此信息。
iOS App ID:根据 iOS App ID,为 Airbridge 深度链接设置 Universal Link 域名。Universal Link 需要此信息。
请按照以下步骤在 Airbridge 面板注册深度链接信息:
1. 请前往 [追踪链接]>[深度链接]。
2. 请在 [iOS URI Scheme] 中输入 iOS URI Scheme,该 URI Scheme 必须与 ://
一起输入。例如,如果 iOS URI Scheme 是 demo
,则输入 demo://
。
3. 请在 Apple Developer Dashboard,进入您要设置深度链接的 App 的 [Identifier] 页面,获取 App ID Prefix 和 Bundle ID。
4. iOS App ID 的格式为 App ID Prefix
+.
+Bundle ID
。请在 Airbridge 面板 [追踪链接]>[深度链接]>[iOS App ID] 中输入 iOS App ID。
例如,如果 App ID Prefix 是 prefix,Bundle ID 是 example,则 iOS App ID 为 prefix.example
。
Android 环境所需的深度链接信息如下:
Android URI Scheme:根据 Android URI Scheme,将 Airbridge 深度链接转换为 URI Scheme 深度链接。App Link 和 URI Scheme 需要此信息。
Android 包名:用于识别 Android 包。App Link 和 URI Scheme 需要此信息。
Android sha256_cert_fingerprints:用于设置 App Link 域名。App Link 需要此信息。
注意
为确保正确的用户跳转,请为正式版 App 和开发用 App 注册不同的深度链接信息。
请按照以下步骤在 Airbridge 面板注册深度链接信息:
1. 请前往 [追踪链接]>[深度链接]。
2. 请在 [Android URI Scheme] 中输入 Android URI Scheme,该 URI Scheme 必须与 ://
一起输入。例如,如果 Android URI Scheme 是 demo
,则输入 demo://
。
3. 请在 [Android 包名] 中输入 Android 包名。
4. 为了获取 sha256_cert_fingerprints,请在部署的 keystore 文件中运行以下命令:
keytool -list -v -keystore YOUR_KEYSTORE.keystore
请查看结果中的 SHA256 值。SHA256 值即是 sha256_cert_fingerprints。
Certificate fingerprints:
MD5: 4C:65:04:52:F0:3F:F8:65:08:D3:71:86:FC:EF:C3:49
SHA1: C8:BF:B7:B8:94:EA:5D:9D:38:59:FE:99:63:ED:47:B2:D9:5A:4E:CC
SHA256: B5:EF:4D:F9:DC:95:E6:9B:F3:9A:5E:E9:D6:E0:D8:F6:7B:AB:79:C8:78:67:34:D9:A7:01:AB:6A:86:01:0E:99
5. 请在 [sha256_cert_fingerprints] 中输入在步骤 4. 获取的 SHA256 值。
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.
请按照以下步骤进行设置,以确保用户点击追踪链接后,App 能通过 Airbridge 深度链接启用。
1. 需要在 App 进行 Airbridge 深度链接的 URI Scheme 深度链接设置。请在 Xcode 中导航至 [YOUR_PROJECT]>[Info]>[URL Types]。
2. 请点击 “+”,并在 URL Schemes 中输入已在 Airbridge 面板中注册的 iOS URI Scheme。
注意
必须输入不包括
://
的 iOS URI Scheme。
3. 需要在 App 进行 Airbridge 深度链接的 Universal Link 设置。请在 Xcode 中导航至 [YOUR_PROJECT]>[Signing & Capabilities]。
4. 请点击 “+ Capability” 以添加 Associated Domains。
5. 请将 applinks:YOUR_APP_NAME.airbridge.io
和 applinks:YOUR_APP_NAME.abr.ge
添加至 Associated Domains。YOUR_APP_NAME
是 Airbridge App 名称。
注意
如果您正在使用或计划使用 Password AutoFill 功能,则必须添加 Webcredentials 域名。否则用户可能会看到通过 Password AutoFill 功能保存的密码域名显示为 airbridge.io 或 abr.ge。
更多信息请参阅 本指南。
1. 需要在 App 进行 Airbridge 深度链接的 URI Scheme 深度链接设置。请在 AndroidManifest.xml
的处理深度链接的 Activity 中添加 Intent Filter。
添加的 Intent Filter 必须使用在 Airbridge 面板中注册的 Android URI Scheme。请输入 Android URI Scheme,不包括 ://
。
<activity ...>
...
<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:scheme="YOUR_SCHEME" />
</intent-filter>
...
</activity>
注意
必须输入不包括
://
的 Android URI Scheme。
2. 为了在 App 设置 Airbridge 深度链接的 App Link,请在 AndroidManifest.xml
的处理深度链接的 Activity 中添加以下 Intent Filter。YOUR_APP_NAME
是 Airbridge App 名称。
<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:scheme="http" android:host="YOUR_APP_NAME.abr.ge" />
<data android:scheme="https" android:host="YOUR_APP_NAME.abr.ge" />
</intent-filter>
<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:scheme="http" android:host="YOUR_APP_NAME.airbridge.io" />
<data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
</intent-filter>
...
</activity>
为了收集深度链接事件,必须将深度链接事件传递给 Airbridge SDK。当 App 通过深度链接启用时,请在调用的 OS 回调顶部调用 Airbridge.trackDeeplink
函数。
请将以下代码添加至 ios/YOUR_PROJECT_NAME/AppDelegate.m
文件中:
import airbridge_flutter_sdk
...
// when app is opened with scheme deeplink
override func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
// track deeplink
AirbridgeFlutter.trackDeeplink(url: url)
return true
}
...
// when app is opened with universal links
override func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
// track deeplink
AirbridgeFlutter.trackDeeplink(userActivity: userActivity)
return true
}
#import <airbridge_flutter_sdk/AirbridgeFlutter.h>
...
// when app is opened with scheme deeplink
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
// track deeplink
[AirbridgeFlutter trackDeeplinkWithUrl:url];
return YES;
}
...
// when app is opened with universal links
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
// track deeplink
[AirbridgeFlutter trackDeeplinkWithUserActivity:userActivity];
return YES;
}
请将以下代码添加至 android/app/src/main/java/.../MainActivity.kt(.java)
文件中:
import co.ab180.airbridge.flutter.AirbridgeFlutter
import android.content.Intent
...
override fun onResume() {
super.onResume()
AirbridgeFlutter.trackDeeplink(intent)
}
...
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
}
import co.ab180.airbridge.flutter.AirbridgeFlutter;
import android.content.Intent;
...
@Override
protected void onResume() {
super.onResume();
AirbridgeFlutter.trackDeeplink(intent);
}
...
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
Airbridge 深度链接被启用后,将被转换为 URI Scheme 深度链接并传递至 OnDeeplinkReceived 回调。非 Airbridge 深度链接则原样传递。
使用接收的深度链接,将用户发送至预设的目标页面。
Airbridge.setOnDeeplinkReceived((deeplink) {
// show proper content using url
});
如需仅接收 Airbridge 深度链接,请在 SDK 设置 中将 isHandleAirbridgeDeeplinkOnly
设置为 true
,以确保回调仅传递 Airbridge 深度链接。详情请参阅 仅收集 Airbridge 深度链接。
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.
Airbridge SDK 在初始化以后,如果满足以下所有条件,会尝试获取深度链接。如果在获取深度链接的过程中 App 被关闭,Airbridge SDK 会将视为没有保存的深度链接。
已设置 Opt-in 时调用 Airbridge.startTracking
函数;或未设置 Opt-in。
用户在 ATT 弹窗中做出选择,或 ATT 弹窗中设置的事件收集延迟时间已到期。
Deferred deep links are automatically passed to OnDeeplinkReceived
, so no additional setup is required.
The SDK functionality test and deep link test allow you to check whether the SDK and deep linking work as intended.
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.
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?