ο»Ώ
(Script tags will be stripped)

## SDK Installation

ο»Ώ

ο»Ώ[![Pub Version](https://img.shields.io/pub/v/airbridge_flutter_sdk?label=version&style=flat-square)](πŸ”—ο»Ώ)ο»Ώ

### Package Installation

#### `pubspec` Setup

Please add the following dependency under the `dependencies` block in your `pubspec.yaml` file

ο»Ώ

Open `Terminal` at the topmost level of the project and execute the following command.

ο»Ώ

The Airbridge Flutter SDK supports `>= Flutter 1.20.0` and `>= Dart 2.12.0`

ο»Ώ

### Project Setup

#### `airbridge.json`

  1. Please add the following under the `flutter/assets` block in your `pubspec.yaml` file.

ο»Ώ
  1. Create an `assets/airbridge.json` file at the topmost level of the project.

  2. Configure settings in JSON format.

ο»Ώ

#### iOS Setup

Add the following code to the `ios/[Project Name]/AppDelegate.m` file.

ο»Ώ

`APP_NAME` can be found on the dashboard at **`Settings β†’ Tokens β†’ App Name`**. `APP_TOKEN` can be found on the dashboard at **`Settings β†’ Tokens β†’ App SDK Token`**.

ο»Ώ

#### Android Setup

Add the following code to the `onCreate` function within the `android/app/src/main/java/.../MainApplication.java` file.

ο»Ώ

`APP_NAME` can be found on the dashboard at **`Settings β†’ Tokens β†’ App Name`**. `APP_TOKEN` can be found on the dashboard at **`Settings β†’ Tokens β†’ App SDK Token`**.

ο»Ώ

Register the `MainApplication` class created above in the `AndroidManifest.xml` file.

ο»Ώ

ο»Ώ

### Common Settings

#### airbridge.json

  1. Add an `airbridge.json` file to the project folder.

  2. Configure settings in JSON format.

ο»Ώ

ο»Ώ

`trackingAuthorizeTimeoutSeconds` in the above code is the default value (0). Please adjust accordingly depending on your user experience and ATT prompt settings. Refer to ]Tracking Authorize Timeout Settings for more details.

NameTypeDefaultDescription
sessionTimeoutSecondsNumber300An app open event will not be sent when the app is reopened within the designated period.
autoStartTrackingEnabledBooleantrueWhen set to false, no events will be sent until `Airbridge.state.startTracking()` is called.
userInfoHashEnabledBooleantrueWhen set to false, user email and user phone information are sent without being hashed.
trackAirbridgeLinkOnlyBooleanfalseWhen set to true, deep link events are sent only when app is opened with an Airbridge deep link.
facebookDeferredAppLinkEnabledBooleanfalseWhen set to true and the Facebook SDK is installed, Facebook Deferred App Link data is collected.
locationCollectionEnabledBooleanfalseWhen set to true, location information is collected. (Android Only) Two permissions must be allowed in AndroidManifest.xml android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_COARSE_LOCATION
trackingAuthorizeTimeoutSecondsNumber0When timeout is set, Install event is delayed until `Request tracking authorization alert` is clicked. (iOS only)
sdkSignatureSecretIDStringnullProtects against SDK spoofing. Both sdkSignatureSecretID and sdkSignatureSecret values must be applied.
sdkSignatureSecretStringnullProtects against SDK spoofing. Both sdkSignatureSecretID and sdkSignatureSecret values must be applied.
logLevelStringwarningAdjusts the log record level for Airbridge. logLevel: "debug" | "info" | "warning" | "error" | "fault"

### Testing the SDK

Check if install events are sent when the application is installed and opened.

#### Check in the Airbridge Dashboard

Events from the Airbridge SDK are shown at the "Airbridge Dashboard β†’ Raw Data β†’ App Real-time Logs".

  1. Go to `Airbridge Dashboard β†’ Raw Data β†’ App Real-time Logs`.

  2. Search for the device's ADID (IDFA, IDFV, GAID).

ο»Ώ

ο»Ώ

Logs may be delayed for up to 5 minutes.

<br><br>

## Deep Link Setup

ο»Ώ

### Dashboard Setup

Please refer to the guides below to setup your deep links in the Airbridge dashboard.

  • iOS Deep Link Dashboard Setup [Guide](πŸ”—ο»Ώ)ο»Ώ

  • Android Deep Link Dashboard Setup [Guide](πŸ”—ο»Ώ)ο»Ώ

ο»Ώ

### Project Setup

#### iOS Deep Link Setup

  • URL Scheme Setup

  1. Go to "Xcode β†’ Project file β†’ Info β†’ URL Types".

  2. From the Airbridge dashboard, copy "iOS URI Scheme" to Xcode's "URL Schemes". (Do not include `://`)

ο»Ώ
  • Universal Link Setup

  1. Go to "Xcode β†’ Project file β†’ Signing & Capabilities".

  2. Click "+ Capability" and add "Associated Domains".

  3. Add `applinks:YOUR_APP_NAME.airbridge.io` to "Associated Domains".

  4. Add `applinks:YOUR_APP_NAME.deeplink.page` to "Associated Domains".

ο»Ώ

`YOUR_APP_NAME` can be found at the "Airbridge dashboard β†’ Settings β†’ Tokens β†’ App Name". Please refer to [Troubleshooting β†’ Webcredentials](πŸ”—ο»Ώ) if you want to use the autofill feature.

  • AppDelegate Setup

  1. Open `ios/[Project name]/AppDelegate`.

  2. Add the following methods. (`handleUniversalLink`, `handleURLSchemeDeeplink`)

ο»Ώ

#### Android Deep Link Setup

  • AndroidManifest.xml Setup

  1. Open AndroidManifest.xml

  2. Add the following intent-filter to the activity that will process the deep link.

ο»Ώ

Enter your app name at `YOUR_APP_NAME`. Enter your scheme value set in the Airbridge dashboard at `YOUR_APP_URI_SCHEME`. (e.g. `abc://`)

  • MainActivity Setup

Insert the following code to the `android/app/src/main/java/.../MainActivity.java` file.

ο»Ώ

#### Callback Setup

Register a function that will be called whenever a "deep link" or a "deferred deep link" opens the application.

ο»Ώ

If `setDeeplinkListener` is called from the `main` function, make sure that `WidgetsFlutterBinding.ensureInitialized();` is called first.

#### Custom Domain (Optional)

Please refer to the below guides to setup your custom domain with Airbridge.

  • ο»Ώ[iOS deep link dashboard setup](πŸ”—ο»Ώ)ο»Ώ

  • ο»Ώ[Android deep link dashboard setup](πŸ”—ο»Ώ)ο»Ώ

ο»Ώ

### Test Deep Link

Click on your URI scheme to test if your deep link has been properly set up in the Airbridge SDK.

  • `YOUR_APP_URI_SCHEME://`

The results will show on the "Airbridge dashboard β†’ Row Data β†’ App Real-time Log" tab if everything is working.

ο»Ώ

<br><br>

## User Setup

ο»Ώ

### User Identifier Setup

### User Identifier Setup

To measure the fragmented contributions of users between web and app, Airbridge collects the following user identifier information.

  • User Email: Email address

  • User Phone: Phone number

  • User ID: Unique User ID (The ID value that specifies the user must be the same in both web and mobile)

  • User Alias: Identifiers that can represent users (e.g. loyalty program ID, affiliate integrated ID, etc)

ο»Ώ

The user's email and phone numbers are hashed (SHA256) by default and then sent to servers.

You can set the user identifier as below for the Airbridge Flutter SDK.

ο»Ώ
NameDescriptionLimitations
idUser ID-
emailUser emailHashed by default (SHA256, can be disabled)
phoneUser phone numberHashed by default (SHA256, can be disabled)
aliasUser alias- Maximum 10 aliases - `"key"` type is String, maximum 128 characters - `"key"` must satisfy `^[a-z_][a-z0-9_]*$` regex - \`"value" type is String, maximum 1024 characters

Once the user identifier has been configured, all events will be forwarded with the corresponding identity information.

ο»Ώ

The user identifier properties can be reset or overwritten through user events.

ο»Ώ

Below is an example of how a particular field can be updated.

ο»Ώ

ο»Ώ

### User Attribute Setup

Additional user attributes can be used for more accurate Multi-Touch Attribution (MTA) analyses, additional internal data analyses, and linking third-party solutions.

ο»Ώ
NameDescriptionLimitations
attributesUser attribute- Maximum 100 attributes - "key" type is string, maximum 128 characters - "key" must satisfy `^[a-z_][a-z0-9_]*$` regex - "value" type is primitive or string - Maximum 1024 characters when "value" is string

ο»Ώ

The user attribute information can be reset or overwritten through user events.

ο»Ώ

### Testing

Make sure that your user information settings are being properly sent through the SDK.

  1. Configure user identifier information.

  2. Send an event using the SDK.

  3. Click the event at "Airbridge dashboard β†’ Raw Data β†’ App Real-time Logs"

  4. Check if the user information is correctly sent under the `user` block.

ο»Ώ

<br><br>

## Device Setup

ο»Ώ

### Setup Device Alias

Setup a device alias through the Airbridge SDK. The alias will be sustained even after the app closes, unless otherwise deleted.

ο»Ώ
ο»Ώ
ο»Ώ
`setDeviceAlias(key: string, value: string)`Add the key value pair to the device identifier.
`removeDeviceAlias(key: string)`Delete the corresponding device alias.
`clearDeviceAlias()`Delete all device aliases.

<br><br>

## Event Setup

ο»Ώ

When important user actions occur, in-app events can be sent to measure performance by channel.

All event parameters are optional. However, more information about the event will help provide a more accurate analysis.

`action`, `label`, `value`, `customAttributes` and `semanticAttributes` can be used for event options.

NameTypeDescription
Event CategoryStringName of the event **Required**
Event ActionStringEvent attribute 1
Event LabelStringEvent attribute 2
Event ValueFloatEvent attribute value
Custom AttributesMap\<String, Object>Custom attributes
Semantic AttributesSemantic Attributes ClassSemantic attributes
ο»Ώ

ο»Ώ

### User Events

Send user events with the SDK.

`action`, `label`, `value`, `customAttributes` and `semanticAttributes` can be used for user events.

#### Sign Up

User identifiers are set with `setUser` and then sent with `AirbridgeCategory.SIGN_UP` for user sign ups.

ο»Ώ

#### Sign In

User identifiers are set with `setUser` and then sent with `AirbridgeCategory.SIGN_IN` for user sign ins.

ο»Ώ

#### Sign Out

Send the sign out event with `AirbridgeCategory.SIGN_OUT`, and then reset the user identifiers with `Airbridge.state.setUser({})`.

ο»Ώ

ο»Ώ

All user identifier properties will disappear after `sign out` is called.

ο»Ώ

### E-commerce Events

#### Send e-commerce events with the SDK.

`action`, `label`, `value`, `customAttributes` and `semanticAttributes` can be used for e-commerce events. It is possible to include product information using `semanticAttributes`. Custom key values can be used as well as the pre-defined values.

#### View Home Screen

ο»Ώ

#### View Product Detail

ο»Ώ

#### View Product List

ο»Ώ

#### View Search Result

ο»Ώ

#### Add To Cart

ο»Ώ

#### Purchase

ο»Ώ

ο»Ώ

To configure and deliver `Semantic Attributes` directly, please refer to this [guide](πŸ”—ο»Ώ).

ο»Ώ

### Verify Event Transmission

Make sure that the events are being properly sent through the SDK.

  1. Send an event with the SDK.

  2. Check if the event shows up at "Airbridge dashboard β†’ Raw Data β†’ App Real-time Logs".

ο»Ώ

<br><br>

## Advanced Setup

ο»Ώ

Please refer to the below guide for advanced settings.

  • ο»Ώ[Advanced Setup Guide](πŸ”—ο»Ώ)ο»Ώ

ο»Ώ

### SDK Signature Setup

Protection against SDK spoofing is possible once you set your SDK Signature. This feature is available for the Airbridge Flutter SDK v3.2.0 and above.

  • Add the following lines in the airbridge.json file.

ο»Ώ

ο»Ώ

Please ask your CSM for the "SDK Signature Secret ID" and "SDK Signature Secret" values.

ο»Ώ

### Uninstall Tracking

ο»Ώ

This feature is available only for Flutter SDK v3.0.2+.

  • Airbridge Android SDK v2.6.0+

  • Airbridge iOS SDK v1.28.2+

Please refer to [this guide](πŸ”—ο»Ώ) for details.

#### Send Push Token

ο»Ώ

Forward the push token to Airbridge using the `registerPushToken` method. Make sure the notification is not shown on the device if the remote message value is `airbridge-uninstall-tracking`.

<br><br>

## Hybrid App Setup

ο»Ώ

While basic events (e.g. "install", "open", "deep link open") can be automatically tracked by only installing the Flutter SDK in your hybrid app, in-app events (e.g. sign-up, purchase, etc.) cannot be tracked as they are actually in-browser events that occur within a website of the WebView environment. Airbridge provides a simpler way to track in-app events by enabling the Flutter SDK to automatically pull all events from the web SDK that is installed on the website of the WebView environment. This replaces the hassle of having to create bridge functions between native and WebView environments.

ο»Ώ

You can control the web interface using `Airbridge.createWebInterface`. Refer to the [Flutter Hybrid App Integration Guide](πŸ”—ο»Ώ) for details.

<br><br>

## Troubleshooting

ο»Ώ

### Update 2.X.X β†’ 3.X.X

The event API has been replaced to the below.

ο»Ώ

Refer to the [Flutter 3.X.X migration guide](πŸ”—ο»Ώ) for details.

ο»Ώ

### Bitcode Compile Error

An error like below may occur when creating iOS builds with Flutter SDK v3.0.1+.

ο»Ώ

Flutter SDK v3.0.1+ uses Airbridge iOS SDK v1.28.0+, and Bitcode is no longer supported. Please refer to the [Bitcode compile error guide](πŸ”—ο»Ώ) for more details.

ο»Ώ

### `settings.gradle` (Android only)

If a `Plugin project ... not found. Please update settings.gradle` error occurs, please edit the `android/settings.gradle` file as below.

ο»Ώ

### Could not find or use auto-linked library...

Flutter issue: <https://github.com/flutter/flutter/issues/16049>

Airbridge Flutter SDK is a Swift plugin, and Flutter has an issue when a 100% Objective C project uses the Swift Plugin. Click `File β†’ New > File... β†’ Swift File` to create an empty Swift file and a bridge header.

Issue does not exist with an "Objective C & Swift Project" or a "100% Swift Project".

ο»Ώ

### Update 1.X.X to 2.X.X

  • iOS

  1. Change the `AirbridgeFL` classes to `AirbridgeFlutter` in the `AppDelegate` file.

  • Android

  1. Change the `AirbridgeFL` classes to `AirbridgeFlutter` in `MainApplication` and `MainActivity`.

  2. Change the `processDeeplinkData` method to `processDeeplink` in `MainActivity`.