> ## Documentation Index
> Fetch the complete documentation index at: https://help.airbridge.io/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Migration - Unity SDK

This article contains the information required to update the Airbridge Unity SDK. We recommend checking the information regarding all versions.

## Update to v4.5.0

When upgrading to Airbridge Unity v4.5.0, the intent filter for Android deep link setup will be moved from `/Assets/Plugins/Android/AndroidManifest.xml` to `/Assets/Plugins/Android/Airbridge.androidlib/AndroidManifest.xml`. You need to manually remove the intent filter within the `/Assets/Plugins/Android/AndroidManifest.xml`.

## Update from v1.x to v4.0

Check the information below when updating the Unity SDK to v4.0.

<Accordion title="List of all changes">
  #### Option

  | Airbridge Settings (v1) | Airbridge Settings (v4) | Change |
  | - | - | - |
  | App Name | App Name | - |
  | App Token | App Token | - |
  | Log Level | Log Level | - |
  | iOS URI Scheme | iOS URI Scheme | - |
  | Android URI Scheme | Android URI Scheme | - |
  | Custom Domain | Custom Domain | Multiple inputs are now supported. |
  | Session Timeout Seconds | Session Timeout Seconds | - |
  | User Info Hash Enabled | User Info Hash Enabled | - |
  | Location Collection Enabled | Location Collection Enabled | - |
  | Track Airbridge Link Only | Track Airbridge Link Only | - |
  | Auto Start Tracking Enabled | Auto Start Tracking Enabled | - |
  | Facebook Deferred App Link Enabled | Facebook Deferred App Link Enabled | - |
  | iOS Tracking Authorize Timeout Seconds | iOS Tracking Authorize Timeout Seconds | - |
  | Sdk Signature Secret ID | SDK Signature Secret ID | The name has been changed. |
  | Sdk Signature Secret | SDK Signature Secret | The name has been changed. |
  | - | Track In Session Life Cycle Event Enabled | New features have been added. |
  | - | Pause Event Transmit On Background Enabled | New features have been added. |
  | - | Clear Event Buffer On Initialize Enabled | New features have been added. |
  | - | SDK Enabled | New features have been added. |
  | - | App Market Identifier | New features have been added. |
  | - | Event Buffer Count Limit | New features have been added. |
  | - | Event Buffer Size Limit In Gibibyte | New features have been added. |
  | - | Event Transmit Interval Seconds | New features have been added. |
  | Meta Install Referrer (Facebook App ID) | Meta Install Referrer (Facebook App ID) | - |
  | In-App Purchase Environment | - | v4.0.0 does not support this feature. |

  #### Function (Unity)

  <Danger>
    **Attention**

    The name of the access function class has been changed from `AirbridgeUnity` to `Airbridge`.
  </Danger>

  | AirbridgeUnity (v1) | Airbridge (v4) | Change |
  | - | - | - |
  | - | EnableSDK | New features have been added. |
  | - | DisableSDK | New features have been added. |
  | IsSDKEnabled | IsSDKEnabled | - |
  | StartTracking | StartTracking | - |
  | StopTracking | StopTracking | - |
  | - | IsTrackingEnabled | New features have been added. |
  | SetUser | - | It has been replaced with functions related to User. |
  | - | SetUserID | New features have been added. |
  | - | ClearUserID | New features have been added. |
  | - | SetUserEmail | New features have been added. |
  | - | ClearUserEmail | New features have been added. |
  | - | SetUserPhone | New features have been added. |
  | - | ClearUserPhone | New features have been added. |
  | - | SetUserAttribute | New features have been added. |
  | - | RemoveUserAttribute | New features have been added. |
  | - | ClearUserAttributes | New features have been added. |
  | - | SetUserAlias | New features have been added. |
  | - | RemoveUserAlias | New features have been added. |
  | - | ClearUserAlias | New features have been added. |
  | ExpireUser | ClearUser | The name has been changed. |
  | ClickTrackingLink | Click | The name has been changed. Callback function has been added. |
  | ImpressionTrackingLink | Impression | The name has been changed. Callback function has been added. |
  | SetDeeplinkCallback | SetOnDeeplinkReceived | The name has been changed. The value has been changed to be received in lambda form. |
  | SetOnAttributionReceived | SetOnAttributionReceived | The value has been changed to be received in lambda form. |
  | TrackEvent | TrackEvent | The method of receiving event information in TrackEvent has changed. |
  | SetDeviceAlias | SetDeviceAlias | - |
  | RemoveDeviceAlias | RemoveDeviceAlias | - |
  | ClearDeviceAlias | ClearDeviceAlias | - |
  | RegisterPushToken | RegisterPushToken | - |
  | CreateWebInterface | - | It has been replaced with functions related to WebInterface. |
  | - | CreateWebInterfaceScript | New features have been added. |
  | - | HandleWebInterfaceCommand | New features have been added. |
  | FetchAirbridgeGeneratedUUID | FetchAirbridgeGeneratedUUID | The callback function has been added. |
  | FetchDeviceUUID | FetchDeviceUUID | onFailure callback has been added. |
  | StartInAppPurchaseTracking | - | v4.0.0 does not support this feature. |
  | StopInAppPurchaseTracking | - | v4.0.0 does not support this feature. |
  | SetOnInAppPurchaseReceived | - | v4.0.0 does not support this feature. |
  | - | IsUninstallTrackingNotification | New features have been added. |

  #### Constant (Unity)

  | Airbridge.Constants.CATEGORY (v1) | AirbridgeCategory (v4) | Change |
  | - | - | - |
  | SIGN\_UP | SIGN\_UP | - |
  | SIGN\_IN | SIGN\_IN | - |
  | SIGN\_OUT | SIGN\_OUT | - |
  | VIEW\_HOME | - | Replace with HOME\_VIEWED. |
  | HOME\_VIEWED | HOME\_VIEWED | - |
  | VIEW\_SEARCH\_RESULT | - | Replaced with SEARCH\_RESULTS\_VIEWED. |
  | SEARCH\_RESULTS\_VIEWED | SEARCH\_RESULTS\_VIEWED | - |
  | VIEW\_PRODUCT\_LIST | - | Replaced with PRODUCT\_LIST\_VIEWED. |
  | PRODUCT\_LIST\_VIEWED | PRODUCT\_LIST\_VIEWED | - |
  | VIEW\_PRODUCT\_DETAILS | - | Replaced with PRODUCT\_VIEWED. |
  | PRODUCT\_VIEWED | PRODUCT\_VIEWED | - |
  | ADD\_TO\_CART | - | Replaced with ADDED\_TO\_CART. |
  | ADDED\_TO\_CART | ADDED\_TO\_CART | - |
  | ORDER\_COMPLETE | - | Replaced with ORDER\_COMPLETED. |
  | ORDER\_COMPLETED | ORDER\_COMPLETED | - |
  | ADD\_PAYMENT\_INFO | ADD\_PAYMENT\_INFO | - |
  | ADD\_TO\_WISHLIST | ADD\_TO\_WISHLIST | - |
  | INITIATE\_CHECKOUT | INITIATE\_CHECKOUT | - |
  | ORDER\_CANCELED | ORDER\_CANCELED | - |
  | START\_TRIAL | START\_TRIAL | - |
  | SUBSCRIBE | SUBSCRIBE | - |
  | UNSUBSCRIBE | UNSUBSCRIBE | - |
  | AD\_IMPRESSION | AD\_IMPRESSION | - |
  | AD\_CLICK | AD\_CLICK | - |
  | COMPLETE\_TUTORIAL | COMPLETE\_TUTORIAL | - |
  | ACHIEVE\_LEVEL | ACHIEVE\_LEVEL | - |
  | UNLOCK\_ACHIEVEMENT | UNLOCK\_ACHIEVEMENT | - |
  | RATE | RATE | - |
  | SHARE | SHARE | - |
  | SCHEDULE | SCHEDULE | - |
  | SPEND\_CREDITS | SPEND\_CREDITS | - |

  | AirbridgeEvent (v1) | AirbridgeAttribute (v4) | Change |
  | - | - | - |
  | SetAction | ACTION | Changed to constant key value. |
  | SetLabel | LABEL | Changed to constant key value. |
  | SetValue | VALUE | Changed to constant key value. |
  | SetTotalValue | - | The feature has been removed. Please enter in VALUE. |
  | SetCurrency | CURRENCY | Changed to constant key value. |
  | originalCurrency | ORIGINAL\_CURRENCY | Changed to constant key value. |
  | SetProducts | PRODUCTS | Changed to constant key value. |
  | SetPeriod | PERIOD | Changed to constant key value. |
  | SetIsRenewal | IS\_RENEWAL | Changed to constant key value. |
  | SetRenewalCount | RENEWAL\_COUNT | Changed to constant key value. |
  | SetProductListId | PRODUCT\_LIST\_ID | Changed to constant key value. |
  | SetCartId | CART\_ID | Changed to constant key value. |
  | SetTransactionId | TRANSACTION\_ID | Changed to constant key value. |
  | SetTransactionType | TRANSACTION\_TYPE | Changed to constant key value. |
  | SetTransactionPairedEventCategory | TRANSACTION\_PAIRED\_EVENT\_CATEGORY | Changed to constant key value. |
  | SetTransactionPairedEventTimestamp | TRANSACTION\_PAIRED\_EVENT\_TIMESTAMP | Changed to constant key value. |
  | SetTotalQuantity | TOTAL\_QUANTITY | Changed to constant key value. |
  | SetQuery | QUERY | Changed to constant key value. |
  | SetInAppPurchased | IN\_APP\_PURCHASED | Changed to constant key value. |
  | SetContributionMargin | CONTRIBUTION\_MARGIN | Changed to constant key value. |
  | SetOriginalContributionMargin | ORIGINAL\_CONTRIBUTION\_MARGIN | Changed to constant key value. |
  | SetListId | LIST\_ID | Changed to constant key value. |
  | SetRateId | RATE\_ID | Changed to constant key value. |
  | SetRate | RATE | Changed to constant key value. |
  | SetMaxRate | MAX\_RATE | Changed to constant key value. |
  | SetAchievementId | ACHIEVEMENT\_ID | Changed to constant key value. |
  | SetSharedChannel | SHARED\_CHANNEL | Changed to constant key value. |
  | SetDatetime | DATE\_TIME | Changed to constant key value. |
  | SetDescription | DESCRIPTION | Changed to constant key value. |
  | SetIsRevenue | IS\_REVENUE | Changed to constant key value. |
  | SetPlace | PLACE | Changed to constant key value. |
  | SetScheduleId | SCHEDULE\_ID | Changed to constant key value. |
  | SetType | TYPE | Changed to constant key value. |
  | SetLevel | LEVEL | Changed to constant key value. |
  | SetScore | SCORE | Changed to constant key value. |
  | - | AD\_PARTNERS | New features have been added. |
  | - | IS\_FIRST\_PER\_USER | New features have been added. |

  | Airbridge.Ecommerce.Product (v1) | AirbridgeAttribute (v4) | Change |
  | - | - | - |
  | SetId | PRODUCT\_ID | Changed to constant key value. |
  | SetName | PRODUCT\_NAME | Changed to constant key value. |
  | SetPrice | PRODUCT\_PRICE | Changed to constant key value. |
  | SetQuantity | PRODUCT\_QUANTITY | Changed to constant key value. |
  | SetCurrency | PRODUCT\_CURRENCY | Changed to constant key value. |
  | SetPosition | PRODUCT\_POSITION | Changed to constant key value. |
  | SetCategoryId | PRODUCT\_CATEGORY\_ID | Changed to constant key value. |
  | SetCategoryName | PRODUCT\_CATEGORY\_NAME | Changed to constant key value. |
  | SetBrandId | PRODUCT\_BRAND\_ID | Changed to constant key value. |
  | SetBrandName | PRODUCT\_BRAND\_NAME | Changed to constant key value. |

  #### Function (Android)

  | AirbridgeUnity (v1) | AirbridgeUnity (v4) | Change |
  | - | - | - |
  | processDeeplinkData | processHandleDeeplink | The name has been changed. |
</Accordion>

### SDK installation and initialization

<Danger>
  **Attention**

  When updating the Airbridge Unity SDK from v1.x.x to v4.0.0, remove the previously imported folders listed below before adding the Airbridge Unity SDK v4.0.0 package.

  * `Assets/Airbridge`
  * `Assets/Plugins/Airbridge`
</Danger>

The key values of `Assets/Airbridge/Resources/AirbridgeData.asset` have been changed. Change the key values as follows.

| AirbridgeData.asset (v1) | AirbridgeData.asset (v4) |
| - | - |
| iosUriScheme | iOSURIScheme |

The `AirbridgeUnity.StartTracking` function has been replaced with the `Airbridge.StartTracking` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeUnity.StartTracking();
+ Airbridge.StartTracking();
```

The `AirbridgeUnity.StopTracking` function has been replaced with the `Airbridge.StopTracking` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeUnity.StopTracking();
+ Airbridge.StopTracking();
```

### Deep Linking

The `AirbridgeUnity.SetDeeplinkCallback` function has been replaced with the `Airbridge.SetOnDeeplinkReceived` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
public class AirbridgeManager : MonoBehaviour
{
    private void Awake()
    {
-        AirbridgeUnity.SetDeeplinkCallback(gameObject.name);
+        Airbridge.SetOnDeeplinkReceived((string url)  =>
+        {
+            // show proper content
+        });
    }
-    // Method will call by Airbridge when deeplink detected
-    private void OnTrackingLinkResponse(string url)
-    {
-        // show proper content
-    }   
}
```

For Android, the `AirbridgeUnity.processDeeplinkData` function has been replaced with the `AirbridgeUnity.processHandleDeeplink` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
package co.ab180.airbridge.unity;

@Override
protected void onResume() {
    super.onResume();
-    AirbridgeUnity.processDeeplinkData(getIntent());
+    AirbridgeUnity.processHandleDeeplink(getIntent());
}
```

### Set up custom domain

In version 1.x, only one custom domain could be specified, but starting from version 4.0, multiple custom domains can be entered.

### In-app event and user data

<Danger>
  **Attention**

  Please enter the value into `AirbridgeAttribute.VALUE` instead of the existing `AirbridgeEvent.SetTotalValue`.

  The logic where `totalValue` overwrites `value` if `totalValue` is used and `value` is defined has been removed from Unity SDK v4.0.0.
</Danger>

The `AirbridgeUnity.TrackEvent` function has been replaced with the `Airbridge.TrackEvent` function.

Replace the `AirbridgeUnity.TrackEvent` function to `Airbridge.TrackEvent` function following the example code below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeEvent @event = new AirbridgeEvent(Airbridge.Constants.CATEGORY.ORDER_COMPLETED);
- // action
- @event.SetAction("Tool");
- // label
- @event.SetLabel("Hammer");
- // value
- @event.SetValue(10);
-         
- // semantic attribute (provided by sdk)
- @event.SetCurrency("USD");
-         
- List<Airbridge.Ecommerce.Product> products = new List<Airbridge.Ecommerce.Product>();
- Airbridge.Ecommerce.Product plasticHammer = new Airbridge.Ecommerce.Product();
- // semantic attribute value (provided by sdk)
- plasticHammer.SetId("12345");
- // semantic attribute value (not provided by sdk)
- plasticHammer.AddData("name", "PlasticHammer");
- products.Add(plasticHammer);
- @event.SetProducts(products.ToArray());
-     
- // semantic attribute (not provided by sdk)
- @event.AddSemanticAttribute("totalQuantity", 1);
-        
- // custom attribute
- @event.AddCustomAttribute("promotion", "FirstPurchasePromotion");
+ Airbridge.TrackEvent(
+    category: AirbridgeCategory.ORDER_COMPLETED,
+    semanticAttributes: new Dictionary<string, object>()
+    {
+        // action
+        { AirbridgeAttribute.ACTION, "Tool" },
+        // label
+        { AirbridgeAttribute.LABEL, "Hammer" },
+        // value
+        { AirbridgeAttribute.VALUE, 10 },
+        // semantic attribute (provided by sdk)
+        { AirbridgeAttribute.CURRENCY, "USD" },
+        {
+            AirbridgeAttribute.PRODUCTS, new List<Dictionary<string, object>>()
+            {
+                new Dictionary<string, object>()
+                {
+                    // semantic attribute value (provided by sdk)
+                    { AirbridgeAttribute.PRODUCT_ID, "12345" },
+                    // semantic attribute value (not provided by sdk)
+                    { "name", "PlasticHammer" }
+                }
+            }
+        },
+        // semantic attribute (not provided by sdk)
+        { "totalQuantity", 1 }
+    },
+    customAttributes: new Dictionary<string, object>()
+    {
+        // custom attribute
+        { "promotion", "FirstPurchasePromotion" }
+    }
+);
```

<Danger>
  **Attention**

  The `AirbridgeEvent` class has been removed.

  The first parameter of the `Airbridge.TrackEvent` function must include `category` information contained in the AirbridgeEvent constructor.

  The second parameter of the `Airbridge.TrackEvent` function must include values from `AirbridgeEvent.SetAction`, `AirbridgeEvent.SetLabel`, `AirbridgeEvent.SetValue`, and `Semantic Attributes`.

  The third parameter of the `Airbridge.TrackEvent` function must include values from the `Custom Attributes`.
</Danger>

The `AirbridgeUnity.SetUser` function has been replaced with the[ Airbridge.SetUser](/en/developers/unity-sdk-v4#send-additional-user-information) related functions. The `SetUser` function is no longer supported.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeUser user = new AirbridgeUser();
- user.SetId("personID");
- user.SetEmail("persondoe@airbridge.io");
- user.SetPhoneNumber("1(123)123-1234");
- user.SetAttribute("key", "value");
- user.SetAlias("key", "value");
- AirbridgeUnity.SetUser(user);
+ Airbridge.SetUserID("personID");
+ Airbridge.SetUserEmail("persondoe@airbridge.io");
+ Airbridge.SetUserPhone("1(123)123-1234");
+ Airbridge.SetUserAttribute("key", "value");
+ Airbridge.SetUserAlias("key", "value");
```

### Additional settings

The `AirbridgeUnity.ImpressionTrackingLink` function has been replaced with the `Airbridge.Impression` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeUnity.ImpressionTrackingLink("https://abr.ge/~~~");
+ Airbridge.Impression(
+    trackingLink: "https://abr.ge/~~~",
+    onSuccess: () =>
+    {
+        // Handle on success
+    },
+    onFailure: (Exception exception) =>
+    {
+        // Handle on failure
+    }
+);
```

The `AirbridgeUnity.ClickTrackingLink` function has been replaced with the `Airbridge.Click` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeUnity.ClickTrackingLink("https://abr.ge/~~~");
+ Airbridge.Click(
+    trackingLink: "https://abr.ge/~~~",
+    onSuccess: () =>
+    {
+        // Handle on success
+    },
+    onFailure: (Exception exception) =>
+    {
+        // Handle on failure
+    }
+);
```

The `AirbridgeUnity.SetOnAttributionReceived` function has been replaced with the `Airbridge.SetOnAttributionReceived` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
public class AirbridgeManager : MonoBehaviour
{
    private void Awake()
    {
-        AirbridgeUnity.SetOnAttributionReceived(gameObject.name);
+        Airbridge.SetOnAttributionReceived((Dictionary<string, object> attributionResult) =>
+        {
+            // using attribution
+        });
    }
-    // Method will call by Airbridge when attribution result received
-    private void OnAttributionResultReceived(string data)
-    {
-        // using attribution
-    }
}
```

#### Device Alias

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- AirbridgeUnity.SetDeviceAlias("ADD_YOUR_KEY", "AND_YOUR_VALUE");
+ Airbridge.SetDeviceAlias("ADD_YOUR_KEY", "AND_YOUR_VALUE");
- AirbridgeUnity.RemoveDeviceAlias("DELETE_THIS_KEY");
+ Airbridge.RemoveDeviceAlias("DELETE_THIS_KEY");
- AirbridgeUnity.ClearDeviceAlias();
+ Airbridge.ClearDeviceAlias();
```

#### Activation status of the Airbridge SDK

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- bool isSDKEnabled = AirbridgeUnity.IsSDKEnabled();
+ bool isSDKEnabled = Airbridge.IsSDKEnabled();
```

The `AirbridgeUnity.CreateWebInterface` function has been replaced with the `Airbridge.CreateWebInterfaceScript`, `Airbridge.HandleWebInterfaceCommand` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
private WebViewObject webViewObject;
string postMessageScript;

- AirbridgeWebInterface webInterface;

void Start()
{
    string PostMessageGenerator(string arg) =>
        $@"
if (window && window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.unityControl) {{
    window.webkit.messageHandlers.unityControl.postMessage({arg});
}} else {{
    var iframe = document.createElement('IFRAME');
    iframe.setAttribute('src', 'unity:' + {arg});
    document.documentElement.appendChild(iframe);
    iframe.parentNode.removeChild(iframe);
    iframe = null;
}}";

-    webInterface = AirbridgeUnity.CreateWebInterface(WebViewController.WebToken, (string command) => PostMessageGenerator(command));
-    postMessageScript = webInterface.Script;
+    postMessageScript = Airbridge.CreateWebInterfaceScript(WebViewController.WebToken, PostMessageGenerator("payload"));
    try
    {
        webViewObject.Init(
            cb: (msg) =>
            {
-                webInterface.Handle(msg);
+                Airbridge.HandleWebInterfaceCommand(msg);
            },
            ...
            ld: (msg) =>
            {
                webViewObject.EvaluateJS(postMessageScript);
            }
            ...
        );
        webViewObject.LoadURL("https://...");
    }
    catch (System.Exception e)
    {
        ...
    }
}
```

<link rel="alternate" hrefLang="en" href="https://help.airbridge.io/en/developers/migration-guide-for-unity-sdk-v4" />

<link rel="alternate" hrefLang="ko" href="https://help.airbridge.io/ko/developers/migration-guide-for-unity-sdk-v4" />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.