Flutter SDK

Flutter SDK

Installlink

Install - Flutterlink

pubspec.yamllink

Add the following to pubspec.yaml.

dependencies:
airbridge_flutter_sdk: 1.0.1

flutter pub getlink

Execute the following command.

flutter pub get

importlink

Import from .dart file.

import 'package:airbridge_flutter_sdk/airbridge.dart';

Install - Androidlink

  • The modules below will be installed automatically.
    • io.airbridge:sdk-android
    • com.android.installreferrer:installreferrer
    • com.google.code.findbugs:jsr305
  • The privileges below will be added automatically.
    • android.permission.INTERNET
    • android.permission.ACCESS_NETWORK_STATE

Proguardlink

If you are using Proguard check the following information.
Add the following text to the 'android/app/proguard-rules.pro' file:

-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient {public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient$newBuilder { public *;}
-keep class com.android.installreferrer.api.InstallReferrerClient$Builder { public *;}
-keep class com.android.installreferrer.api.ReferrerDetails {public *;}
-keep class com.android.installreferrer.api.InstallReferrerStateListener {public *;}
-keep class io.airbridge.deviceinfo.** { *; }
-keepclassmembers class io.airbridge.** { public *; }
-keep public class io.airbridge.**

MainApplicationlink

  1. Add file android/app/src/main/java/.../MainApplication.

  2. Please add the following code.

class MainApplcation: FlutterApplication() {
override fun onCreate() {
AirbridgeFL.init(this, "YOUR_APP_NAME(앱 이름)", "YOUR_APP_TOKEN(앱 토큰)")
super.onCreate()
}
}

'App name' can be found on the dashboard at 'App Setting > App Info'.
'App token' can be found on the dashboard at 'App Setting > Tokens Management'.

AndroidManifest.xmllink

In android/app/src/main/AndroidManifest.xml add the following attribute to the application tag.

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

Install - iOSlink

AppDelegatelink

Add the following code to the import section of the file ios/[Project Name]/AppDelegate.

import airbridge_flutter_sdk

Add the following code to the function application:idFinishLaunchingWithOptions: in the file ios/[Project Name]/AppDelegate.

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
AirbridgeFL.getInstance("YOUR_APP_TOKEN", appName: "YOUR_APP_NAME", withLaunchOptions: launchOptions)
...
}

'App name' can be found on the dashboard at 'App Setting > App Info'.
'App token' can be found on the dashboard at 'App Setting > Tokens Management'.

Register the information in your app to the Airbridge dashboard to use the Deeplink feature.
On the Airbridge dashboard, click the Deeplinks menu in the sidebar and you will see the screen as shown below.

deeplinks

Schemelink

  1. Enter the app name + "://" in the Android URI scheme area of the picture in Deeplink Registration part

Example) APP_NAME://

  1. Prepare the signing key used to register with Google Play Store.

  2. Execute the following command.

keytool -list -v -keystore my-release-key.keystore
  1. Copy the SHA256 column of Certificate fingerprints and paste to Android sha256_certs_fingerprints area of the picture in Deeplink Registration part.

Example) 14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5

Schemelink

  1. Enter the desired scheme in the iOS URI scheme area of the Deeplink registration part picture by attaching "://"

example) scheme://

  1. Connect to the link below.

  2. Click the app name of the project.

  3. Copy the string in the Prefix and ID area of the picture below and enter the string Prefix + "." + ID in the iOS App ID area of the picture in the part.

Example) 9JA89QQLNQ.com.apple.wwdc

ios app id

Set up the app to use deeplink.

setDeeplinkListenerlink

Register a callback called when Deeplink or Deferred Deeplink occurs.

Airbridge.deeplink.setDeeplinkListener((deeplink) {
// Code to be executed when a `Deeplink` or `Deferred Deeplink` occurs
// deeplink = https://appname.airbridge.io/...
print('$deeplink');
});

setDeferredDeeplinkListener (Option)link

Register a callback called when Deferred Deeplink occurs.

Airbridge.deeplink.setDeferredDeeplinkListener((deeplink) {
// Code to be executed when a `Deferred Deeplink` occurs
// deeplink = https://appname.airbridge.io/...
print('$deeplink');
});

AndroidManifest.xmllink

In the MainActivity area of the file android/app/src/main/AndroidManifest.xml, insert the intent-filter as shown below.

<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.deeplink.page" />
<data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
</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>
<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="EXAMPLE_SCHEME" />
</intent-filter>

Enter the app name to YOUR_APP_NAME
Enter the scheme value set in the dashboard to EXAMPLE_SCHEME

MainActivitylink

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

override fun onResume() {
super.onResume()
AirbridgeFL.getDeeplink().fetch(getIntent())
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
}

Xcodelink

Schemelink

  1. Xcode > Project file > Info > URL Types.
  2. Put scheme value set in the dashboard to identifier and URL Schemes.

ios url scheme

Remove the :// and insert it.

  1. Xcode > Project File > Signing & Capabilities > Associated Domains.
  2. Click + button and add applinks:YOUR_APP_NAME.airbridge.io.
  3. Click + button and add applinks:YOUR_APP_NAME.deeplink.page.

'YOUR_APP_NAME' can be found on the dashboard at 'App Setting > App Info'.

AppDelegatelink

Schemelink

  1. Open ios/[Project Name]/AppDelegate file.
  2. Insert below code.
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
{
print("openURL : \(url)")
AirbridgeFL.deeplink().handleURLSchemeDeeplink(url, withSourceBundle: options[.sourceApplication] as? String)
return true
}
  1. If you are targeting iOS 8.x or earlier, insert the following additional code.
func application(_ application: UIApplication,
open url: URL,
sourceApplication: String?,
annotation: Any) -> Bool
{
print("openURL : \(url)")
AirbridgeFL.deeplink().handleURLSchemeDeeplink(url, withSourceBundle: sourceApplication);
return true;
}
  1. Open ios/[Project Name]/AppDelegate file.
  2. Insert below code.
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
{
print("continueUserActivity : \(userActivity.webpageURL)")
if let webpageURL = userActivity.webpageURL {
AirbridgeFL.deeplink().handleUniversalLink(webpageURL)
}
return true
}

Verify Installation Completionlink

  1. Delete the app from the test device.
  2. Reinstall the app and run the app on the same test device.
  3. Press on Realtime Log under Airbridge Dashboard → Select Apps → Log Data.
  4. Press Mobile SDK Log and enter Android GAID or iOS IDFA in Device UUID..
  • If device UUID (Android GAID or iOS IDFA) exposure is not confirmed, please re-check that it is installed as directed in install.
  • Log exposure can be delayed by up to 5 minutes.
  • Confirm Android GAID: 'Setup' → Google Setup → Advertise → 'Check My Advertisement ID' is the value of Android GAID.

In app eventlink

You can measure various user journey events through the Android SDK.

There are 9 basic events related to users' information and e-commerce user journeys. Custom events can be additionally defined as well.

Information that is attached to all events can be additionally added.
You would be able to track and analyze more accurate statistics if you include more event information.

EventOption objectlink

All events in Airbridge can be specified through EventOption.

NameTypeOptionalDescription
actionStringOptionalvent subclass 1
labelStringOptionalvent subclass 2
valuenumOptionalEvent custom value
attributesMap<String, String>OptionalEvent custom information

About action, label, check in-app event classification part.

In-app event - Userlink

User in-app events are a component of 'Cross Platform User Matching'.
If possible, please send more than one type of user information.

When sign-up or sign-in event occurs,
until the next sign-out event occurs, all events are recorded as being triggered by that user.

When sign-out event occurs,
all events until the next sign-in event are recorded without that user-related data.

All user information is sent by default in a hashed format (SHA256).

User objectlink

Object that has product information.

NameTypeOptionalDescription
idStringOptionalUser ID
emailStringOptionalUser email
phoneStringOptionalUser cell-phone-number

Sign uplink

When a user sign-up, send SignUpEvent.

SignUpEventlink

  1. Send sign-up event.
  2. Setting up users that will be applied to the next events.
Parameter :
NameTypeOptionalDescription
userUserOptionalUser information
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(SignUpEvent(
user: User(
id: 'test',
email: 'test@ab180.co',
phone: '000-0000-0000',
)
));

Sign Inlink

When a user sign-in, send SignInEvent.

SignInEventlink

  1. Send sign-in event.
  2. Setting up users that will be applied to the next events.
Parameter :
NameTypeOptionalDescription
userUserOptionalUser information
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(SignInEvent(
user: User(
id: 'test',
email: 'test@ab180.co',
phone: '000-0000-0000',
)
));

Sign Outlink

If the user signs out, send SignOutEvent.

SignOutEventlink

  1. Send sign-out event.
  2. Remove users that will be applied to the next events.
Parameter :
NameTypeOptionalDescription
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(SignOutEvent());

In-app events - Commercelink

Track the user's commerce-related behavior.

Product objectlink

Object that has product information.

NameTypeOptionalDescription
idStringOptionalProduct unique ID
nameStringOptionalProduct name
currencyStringOptionalCurrency
According toISO 4217 standard
pricenumOptionalProduct price
quantitynumOptionalProduct quantity
positionnumOptionalPosition of the products on the list

Home screen lookuplink

When the user navigates to the app's home screen, send ViewHomeEvent.

ViewHomeEventlink

Send home-screen-lookup event.

Parameter :
NameTypeOptionalDescription
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(ViewHomeEvent());

Product list lookuplink

When the user views the product list, send ViewProductListEvent.

ViewProductListEventlink

Send product-list-lookup event.

Parameter :link

NameTypeOptionalDescription
listIDStringOptionalUnique ID for a product list
productsList<Product>OptionalProduct list
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(ViewProductListEvent(
listID: 'ID-1234567890',
products: [
Product(
name: 'product A',
),
Product(
name: 'product B',
),
]
));
  • When users scroll through the list and load new information
    Additional loaded product information, it is recommended that create new event and send it separately.

Search results lookuplink

When the user searches for a product, send ViewSearchResultEvent.

ViewSearchResultEventlink

Send search-results-lookup event.

Parameter :link

NameTypeOptionalDescription
queryStringOptionalSearch term
productsList<Product>OptionalProduct list of the search result
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(ViewSearchResultEvent(
query: 'product A',
products: [
Product(
name: 'product A AAA'
),
Product(
name: 'product A BBB',
),
],
));

Product details lookuplink

When user views the details of the product, send ViewProductDetailEvent.

ViewProductDetailEventlink

Send product-details-lookup event.

Parameter :link

NameTypeOptionalDescription
productsList<Product>OptionalProduct list of lookup
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(ViewProductDetailEvent(
products: [
Product(
name: 'product A',
),
],
);

Add to shopping cartlink

When user adds the product in the cart, send AddToCartEvent.

AddToCartEventlink

Send add-to-shopping-cart event.

Parameter :link

NameTypeOptionalDescription
cartIDStringOptionalUnique ID of shopping cart
productsList<Product>OptionalProduct list of shopping cart
currencyStringOptionalCurrency
According to ISO 4217 standard
totalnumOptionalTotal price of products
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(AddToCartEvent(
cartID: 'ID-1234567890',
products: [
Product(
name: 'product A',
),
],
currency: 'KRW',
total: 50000,
);

Purchaselink

When user purchase, send PurchaseEvent.

PurchaseEventlink

Send purchase event.

Parameter :link

NameTypeOptionalDescription
transactionIDStringOptionalUnique ID of purchase
productsList<Product>OptionalProduct list of shopping cart
isInAppPurchaseboolOptionalIs from in-app-purchase?
currencyStringOptionalCurrency
According to ISO 4217 standard
totalnumOptionalTotal price of products
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(PurchaseEvent(
transactionID: 'transactionID-purchase',
products: [
Product(
name: 'product purchase A name',
id: 'product purchase A id',
price: 100,
quantity: 10,
),
],
isInAppPurchase: true,
currency: 'KRW',
total: 50000,
);

In-app Event - Customlink

Customize and use in-app event.

Eventlink

Send custom event.

Parameter :link

NameTypeOptionalDescription
categoryStringRequiredEvent name
optionEventOptionOptionalEvent additional information

Example codelink

Airbridge.event.send(Event(
'custom',
option: EventOption(
action: 'Action custom',
label: 'Label custom',
value: 9999,
attributes: {
'custom': 'value custom',
},
),
));

Settingslink

Set the behavior of the Airbridge SDK according to the developer's intention.

In-app event classificationlink

The Airbridge dashboard displays statistics by separating events according to Category, Action, and Label.

Category is a name that you choose as a way to group events that you want to analyze.
Action is used to define the subgroups for a particular event Category.
Label is used to further define the subgroups for a particular Action.

For all in-app events, you can modify Action and Label.

Example codelink

for(var i=0; i<10; i++) {
Airbridge.event.send(SignUpEvent(
user: User(
id: 'test',
),
option: EventOption(
action: 'Seoul',
label: '30s',
)
);
}
for(var i=0; i<20; i++) {
Airbridge.event.send(SignUpEvent(
user: User(
id: 'test',
),
option: EventOption(
action: 'Seoul',
label: '40s',
)
);
}
for(var i=0; i<15; i++) {
Airbridge.event.send(SignUpEvent(
user: User(
id: 'test',
),
option: EventOption(
action: 'Busan',
label: '30s',
)
);
}
for(var i=0; i<8; i++) {
Airbridge.event.send(PurchaseEvent(
transactionID: 'ID-1234567890',
option: EventOption(
action: 'Product A',
label: 'Option B',
)
)
}
for(var i=0; i<7; i++) {
Airbridge.event.send(PurchaseEvent(
transactionID: 'ID-1234567890',
option: EventOption(
action: 'Product A',
label: 'Option C',
)
)
}
for(var i=0; i<10; i++) {
Airbridge.event.send(Event(
'Subscription',
option: EventOption(
action: 'Normal',
),
));
}
for(var i=0; i<5; i++) {
Airbridge.event.send(Event(
'Subscription',
option: EventOption(
action: 'Premium',
),
));
}

You can view statistics for the count of each event based on Category in the Airbridge dashboard.
You can view statistics by separating the events in the same Category with the action and then separating the events through the label.

As a result, you can get the following results on the dashboard.

CategoryActionLabelCount
Sign upSeoul30s10
Sign upSeoul40s20
Sign upBusan30s15
PurchaseProduct AOption B8
PurchaseProduct AOption C7
SubscriptionNormal10
SubscriptionPremium5

Session durationlink

The default value of session duration in Airbridge is 5 minutes.

You can set the session period by calling the code below.

...
[AirbridgeFL setSessionTimeout:(1000 * 60 * 5)];
[AirbridgeFL getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
...

The session period is in milliseconds. The maximum value is 604800000 (7 days).

Both Android and iOS should be set before initialization.

Disable hashing of user informationlink

All information about the user is by default sent in a hashed format (SHA256).

If you do not want to hash the information, you can use the method below to change the settings.

...
// Enable user information hash
[AirbridgeFL setIsUserInfoHashed:YES];
[AirbridgeFL getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
...

Both Android and iOS should be set before initialization.

Stop tracking (Opt-out)link

You can stop sending events from the SDK.

...
// Stop tracking
[AirbridgeFL setIsTrackingEnabled:NO];
[AirbridgeFL getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
...

true : Tracking
false : Stop Tracking

Both Android and iOS should be set before initialization.

Additional Collectionlink

You can gather more additional information.

User carrier name collection (Android)link

You can collect the name of the android user's carrier.

Add the following permissions to the android/app/src/main/AndroidManifest.xml file.

...
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
...

This setting increases the accuracy of cross-platform user matching.

You can use the code below to perform deeplink actions on the App and track the behavior.

Airbridge.placement.click('https://abr.ge/~~~', 'ablog://main', 'https://airbridge.io');
Airbridge.placement.impression('https://abr.ge/~~~');

clicklink

click function +1 click statistic for the tracking link and moves to the set App, Web, or Fallback.
When the tracking link is clicked, call click function.

In click function, deeplink and fallback are backup links used when there is no Internet connection.
Deeplink parameters are only available in Custom URL Scheme format.
(All of these are optional parameters.)

impressionlink

impression function +1 impression statistic for the 'tracking link'.
When the tracking link is displayed on the UI, call impression function.

If you are using custom domain, you cannot use tracking link using custom short ID.
example: http://deeplink.ab180.co/custom -> Unavailable
example: http://deeplink.ab180.co/a3b1c2 -> Available
example: https://abr.ge/a3b1c2 -> Available

Advancedlink

Manual setting for user informationlink

Even without sign-up, sign-in and sign-out events, you can still set the user information manually.

When user information is set manually, until next setting or using the function signIn, signUp, and signOut. all events are recorded as being triggered by the user.

setUserlink

Change the current user.

Parameter :link

NameTypeOptionalDescription
userUserOptionalUser information

Replace the current user with the user entered.

updateUserlink

Modify the current user information.

Parameter :link

NameTypeOptionalDescription
userUserOptionalUser information

If the user entered has no ID value, the ID of the current user is not modified.
If the user entered has an ID value, modify the ID of the current user.

Example codelink

Airbridge.state.setUser(
User(
id: 'test1',
email: 'test1@ab180.co',
)
);
Airbridge.state.setUser(
User(
email: 'test2@ab180.co',
phone: '222-2222-2222',
)
);
Airbridge.state.updateUser(
User(
id: 'test3',
)
);

The code above works as follows.

User = { ID: 'test1', email: 'test1@ab180.co' }
-> User = { email: 'test1@ab180.co', phone: '222-2222-2222' }
-> User = { ID: 'test3', email: 'test2@ab180.co', phone: '222-2222-2222' }

Braze Integrationlink

Use SDK to SDK method to send Airbridge attribution information to Braze.

iOSlink

#import <AirBridge/AirBridge.h>
...
@interface AppDelegate () <ABTrackingDelegate>
@end
@implementation AppDelegate
...
- (void)airbridgeUserAttributed:(ABAttribution *)attribution {
/* convert airbridge-attribution to braze-attribution */
ABKAttributionData *abkAttributionData = [[ABKAttributionData alloc] initWithNetwork:attribution.source
campaign:attribution.campaign
adGroup:attribution.adgroup
creative:attribution.adcreative];
/* add attribution-data to user */
[[[Appboy sharedInstance] user] setAttributionData:abkAttributionData];
[[[Appboy sharedInstance] user] setCustomAttributeWithKey:@"airbridge_medium"
andStringValue:attribution.medium];
[[[Appboy sharedInstance] user] setCustomAttributeWithKey:@"airbridge_ad_content"
andStringValue:attribution.adcontent];
[[[Appboy sharedInstance] user] setCustomAttributeWithKey:@"airbridge_search_keyword"
andStringValue:attribution.searchKeyword];
/* send event to Braze */
[[Appboy sharedInstance] flushDataAndProcessRequestQueue];
}
...
@end

Androidlink

Modify android/app/src/main/java/.../MainApplication.java.

import io.airbridge.AirBridge;
...
@Override
public void onCreate() {
super.onCreate();
...
/* Braze init */
registerActivityLifecycleCallbacks(new AppboyLifecycleCallbackListener(...));
...
/* Airbridge-Flutter-SDK init */
AirbridgeFL.init(this, "YOUR_APP_NAME", "YOUR_APP_TOKEN");
/* Braze integration with Airbridge-Android-SDK */
AirBridge.turnOnIntegration(new AppBoyIntegrator());
}

The code related to Airbridge-Braze integration should be written below Braze init.