Unity SDK

Unity SDK

Installlink

  • Download the latest version of Airbridge Unity SDK

  • Go to Assets > Import Package > Custom Package ... and import the downloaded package file.

  • Once the package is installed, AB180 tab appears on the menu

Configurationlink

  • Click AB180 > Airbridge Settings menu and will see the following screen

unity airbridge settings

  • Each field takes following input
NameDesc
App NameApp name in Settings > Tokens on the Airbridge dashboard
App TokenApp SDK token in Settings > Tokens on the Airbridge dashboard
iOS URI SchemeiOS URI Scheme in Tracking Link > iOS on the Airbridge dashboard
Android URI SchemeAndroid URI Scheme in Tracking Link > Android on the Airbridge dashboard
Reopen Session Timeout SecondsApplication reopen session hold time (Min. 0 sec ~ Max. 604,800 sec)
Auto Start User TrackingWhether to start automatic tracking (details)

Press Update iOS App Setting or Update Android Manifest to apply changes

Testlink

  • You can check your events into 'Raw Data > App Real-time Log' page on the dashboard after run your application

Real-time Log can take delay up to 5 minutes

unity airbridge test en

Initializationlink

  • For Airbridge Unity, no additional initialization is required

In special cases, each platform may require separate migration work.
For more information, please check the Troublishing section.

Identifierlink

  • Airbridge Unity can set up a unique identifier for the events in the following ways
AirbridgeIdentifier identifier = new AirbridgeIdentifier();
identifier.SetUserId(UserId);
identifier.SetUserEmail(Email);
identifier.SetUserPhoneNumber(Phone);
AirbridgeUnity.SetIdentifier(identifier);

User events can automatically change the identifier information.
For more information, please check the User events section.

Eventslink

  • Airbridge Unity can send events in the following ways
AirbridgeEvent @event = new AirbridgeEvent("category");
@event.SetAction("action");
@event.SetLabel("label");
@event.SetValue(value);
AirbridgeUnity.SendEventData(@event);
  • Airbridge Unity can send events using predefined formats, such as user or e-commerce events.

User eventslink

Identifier information may change automatically when sending user event. If you do not want this, use a custom events with the identifier.

1. Sign up eventlink

AirbridgeIdentifier identifier = new AirbridgeIdentifier.Builder()
.SetUserId(UserId)
.SetUserEmail(Email)
.SetUserPhoneNumber(Phone)
.build();
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.SIGN_UP);
@event.SetIdentifier(identifier);
AirbridgeUnity.SendEventData(@event);

The identifier information in Airbridge Unity will automatically change when it send with the identifier.

2. Sign in eventlink

AirbridgeIdentifier identifier = new AirbridgeIdentifier.Builder()
.SetUserId(UserId)
.SetUserEmail(Email)
.SetUserPhoneNumber(Phone)
.build();
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.SIGN_IN);
@event.SetIdentifier(identifier);
AirbridgeUnity.SendEventData(@event);

The identifier information in Airbridge Unity will automatically change when it send with the identifier.

3. Sign out eventlink

AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.SIGN_OUT);
AirbridgeUnity.SendEventData(@event);

The identifier information in Airbridge Unity is automatically reset when a Sign out event is called.

E-commerce eventslink

1. Home view eventlink

AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.VIEW_HOME);
AirbridgeUnity.SendEventData(@event);

2. Search result view eventlink

List<Airbridge.Ecommerce.Product> beverages = new List<Airbridge.Ecommerce.Product>();
Airbridge.Ecommerce.Product cocacola = new Airbridge.Ecommerce.Product();
cocacola.SetId("beverage_1");
cocacola.SetName("Coca Cola");
cocacola.SetPrice(1.25f);
cocacola.SetCurrency("USD");
cocacola.SetQuantity(1);
cocacola.SetPosition(0);
beverages.Add(cocacola);
Airbridge.Ecommerce.Product fanta = new Airbridge.Ecommerce.Product();
fanta.SetId("beverage_3");
fanta.SetName("Fanta");
fanta.SetPrice(1500f);
fanta.SetCurrency("KRW");
fanta.SetQuantity(1);
fanta.SetPosition(2);
beverages.Add(fanta);
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.VIEW_SEARCH_RESULT);
@event.SetQuery("SELECT * FROM beverages");
@event.SetProducts(beverages.ToArray());
AirbridgeUnity.SendEventData(@event);

3. Product list eventlink

List<Airbridge.Ecommerce.Product> beverages = new List<Airbridge.Ecommerce.Product>();
Airbridge.Ecommerce.Product cocacola = new Airbridge.Ecommerce.Product();
cocacola.SetId("beverage_1");
cocacola.SetName("Coca Cola");
cocacola.SetPrice(1.25f);
cocacola.SetCurrency("USD");
cocacola.SetQuantity(1);
cocacola.SetPosition(0);
beverages.Add(cocacola);
Airbridge.Ecommerce.Product fanta = new Airbridge.Ecommerce.Product();
fanta.SetId("beverage_3");
fanta.SetName("Fanta");
fanta.SetPrice(1500f);
fanta.SetCurrency("KRW");
fanta.SetQuantity(1);
fanta.SetPosition(2);
beverages.Add(fanta);
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.VIEW_PRODUCT_LIST);
@event.SetProductListId("beverage_list_0");
@event.SetProducts(beverages.ToArray());
AirbridgeUnity.SendEventData(@event);

4. Product details eventlink

Airbridge.Ecommerce.Product cocacola = new Airbridge.Ecommerce.Product();
cocacola.SetId("beverage_1");
cocacola.SetName("Coca Cola");
cocacola.SetPrice(1.25f);
cocacola.SetCurrency("USD");
cocacola.SetQuantity(1);
cocacola.SetPosition(0);
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.VIEW_PRODUCT_DETAILS);
@event.SetProducts(cocacola);
AirbridgeUnity.SendEventData(@event);

5. Add to cart eventlink

Airbridge.Ecommerce.Product cocacola = new Airbridge.Ecommerce.Product();
cocacola.SetId("beverage_1");
cocacola.SetName("Coca Cola");
cocacola.SetPrice(1.25f);
cocacola.SetCurrency("USD");
cocacola.SetQuantity(1);
cocacola.SetPosition(0);
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.ADD_TO_CART);
@event.SetProducts(cocacola);
AirbridgeUnity.SendEventData(@event);

6. Order complete eventlink

List<Airbridge.Ecommerce.Product> beverages = new List<Airbridge.Ecommerce.Product>();
Airbridge.Ecommerce.Product cocacola = new Airbridge.Ecommerce.Product();
cocacola.SetId("beverage_1");
cocacola.SetName("Coca Cola");
cocacola.SetPrice(1.25f);
cocacola.SetCurrency("USD");
cocacola.SetQuantity(1);
cocacola.SetPosition(0);
beverages.Add(cocacola);
Airbridge.Ecommerce.Product fanta = new Airbridge.Ecommerce.Product();
fanta.SetId("beverage_3");
fanta.SetName("Fanta");
fanta.SetPrice(1500f);
fanta.SetCurrency("KRW");
fanta.SetQuantity(1);
fanta.SetPosition(2);
beverages.Add(fanta);
AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.ORDER_COMPLETE);
@event.SetTransactionId("transaction_123");
@event.SetProducts(beverages.ToArray());
@event.SetInAppPurchased(true);
AirbridgeUnity.SendEventData(@event);

Configurationlink

unity airbridge deeplink en

Usagelink

  • Following method is requiring the class name for receiving deeplink data that user clicks on
private void Awake()
{
AirbridgeUnity.SetDeeplinkCallback("AirbridgeManager");
}
  • The class will get deeplink URL with the following method
// Method will call by Airbridge when deeplink detected
private void OnTrackingLinkResponse(string url)
{
}

Airbridge Unity is internally using UnitySendMessage method

Additional collectionlink

  • Airbridge Unity can optionally collect additional data
  • Airbridge Unity can execute and track tracking links in the following ways

1. Clicklink

  • Add 1 click statistic of the tracking link and move to application or web page
AirbridgeUnity.ClickTrackingLink("https://abr.ge/~~~", "ablog://main", "https://airbridge.io");

2. Impressionlink

  • Add 1 impression statistic of the tracking link
AirbridgeUnity.ImpressionTrackingLink("https://abr.ge/~~~");

Carrier information collectionlink

Only available on Android platform

  • The feature helps to improve user identification accuracy

  • Please add the following permission into Project > Plugins > Android > AndroidManifest.xml file for collecting user's carrier information

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

Data collectionlink

  • If data collection requires special handling of conditions such as GDPR, you can stop or start in the following ways
// true : stop data collection false : start data collection
AirbridgeUnity.SetLimitUserTracking(true);

If you set Auto Start User Tracking to False in configuration, the SDK will not collect data from the device until you call AirbridgeUnity.SetLimitUserTracking (false)

Troubleshootinglink

Androidlink

1. Airbridge Unity seems not initialize correctlylink

  • Airbridge Unity for Android is initialiing automatically through Content Provider. For proper initialization, the following Xml Tag must be correctly place in Project > Plugins > Android > AndroidManifest.xml
<provider
android:authorities="${applicationId}.co.ab180.airbridge.unity.AirbridgeContentProvider"
android:name="co.ab180.airbridge.unity.AirbridgeContentProvider"
android:exported="false" />

2. Using your own Custom Activity Classlink

  • Airbridge Unity uses Custom Activity that extended UnityPlayerActivity to get deeplink data. If you are using your own Custom Activity class, please override the following codes inside your Custom Activity class.
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
@Override
protected void onResume() {
super.onResume();
AirbridgeUnity.processDeeplinkData(getIntent());
}

3. Android Manifest file seems not merge properlylink

  • Android Manifest Merger that Airbridge Unity provided is simple component that merging between Project > Plugins > Android > AndroidManifest.xml and Project > Plugins > Airbridge > Android> AndroidManifest.xml file. The merger cannot be satisfy all user cases. In this situation, it has to create own AndroidManifest.xml file with reference to Project > Plugins > Airbridge > Android> AndroidManifest.xml file.

iOSlink

1. Using your own Custom AppControllerlink

  • Airbridge Unity SDK uses IMPL_APP_CONTROLLER_SUBCLASS to create a Custom AppController. If you are using your own Custom AppController, please add the following codes inside your Custom AppController.
- (BOOL) application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>>* _Nullable))restorationHandler
{
[AUAppDelegate.instance application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
return YES;
}
  • After that please remove Assets > Plugins > Airbridge > iOS > Delegate > AUAppController.mm file.