> ## 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 - Cordova-Ionic SDK

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

## Update from v2.x to v4.0

Check the information below when updating the Airbridge Cordova-Ionic SDK to v4.0.

##### List of all changes

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

  | airbridge.json (v2)             | airbridge.json (v4)                               | Change                        |
  | ------------------------------- | ------------------------------------------------- | ----------------------------- |
  | -                               | sdkEnabled                                        | New features have been added. |
  | logLevel                        | logLevel                                          | -                             |
  | autoStartTrackingEnabled        | autoStartTrackingEnabled                          | -                             |
  | trackingAuthorizeTimeoutSeconds | autoDetermineTrackingAuthorizationTimeoutInSecond | The name has been changed.    |
  | facebookDeferredAppLinkEnabled  | trackMetaDeferredAppLinkEnabled                   | The name has been changed.    |
  | sessionTimeoutSeconds           | sessionTimeoutInSecond                            | The name has been changed.    |
  | metaInstallReferrer             | metaInstallReferrerAppID                          | The name has been changed.    |
  | trackAirbridgeLinkOnly          | trackAirbridgeDeeplinkOnlyEnabled                 | The name has been changed.    |
  | -                               | trackInSessionLifecycleEventEnabled               | New features have been added. |
  | userInfoHashEnabled             | hashUserInformationEnabled                        | The name has been changed.    |
  | sdkSignatureSecretID            | sdkSignatureID                                    | The name has been changed.    |
  | sdkSignatureSecret              | sdkSignatureSecret                                | The name has been changed.    |
  | -                               | clearEventBufferOnInitializeEnabled               | New features have been added. |
  | -                               | eventBufferCountLimit                             | New features have been added. |
  | -                               | eventBufferSizeLimitInGibibyte                    | New features have been added. |
  | -                               | eventTransmitIntervalInSecond                     | New features have been added. |

  #### Function (Cordova)

  | Airbridge (v2)               | Airbridge (v4)                  | Change                                                                |
  | ---------------------------- | ------------------------------- | --------------------------------------------------------------------- |
  | state.setAttributionListener | setOnAttributionReceived        | The name has been changed.                                            |
  | deeplink.setDeeplinkListener | setOnDeeplinkReceived           | The name has been changed.                                            |
  | event.trackEvent             | trackEvent                      | The name has been changed. Method of inserting attributes is changed. |
  | state.deviceUUID             | fetchDeviceUUID                 | The name has been changed. DeviceUUID is now returned with callback.  |
  | -                            | fetchAirbridgeGeneratedUUID     | New features have been added.                                         |
  | -                            | isUninstallTrackingNotification | New features have been added.                                         |
  | placement.click              | click                           | The name has been changed. Callback feature is added.                 |
  | placement.impression         | impression                      | The name has been changed. Callback feature is added.                 |
  | state.setUser                | -                               | Replaced with User related functions.                                 |
  | state.updateUser             | -                               | Replaced with User related functions.                                 |
  | -                            | 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.                                         |
  | -                            | clearUser                       | New features have been added.                                         |
  | setDeviceAlias               | setDeviceAlias                  | -                                                                     |
  | removeDeviceAlias            | removeDeviceAlias               | -                                                                     |
  | clearDeviceAlias             | clearDeviceAlias                | -                                                                     |
  | registerPushToken            | registerPushToken               | -                                                                     |
  | -                            | enableSDK                       | New features have been added.                                         |
  | -                            | disableSDK                      | New features have been added.                                         |
  | -                            | isSDKEnabled                    | New features have been added.                                         |
  | state.startTracking          | startTracking                   | The name has been changed.                                            |
  | -                            | stopTracking                    | New features have been added.                                         |
  | -                            | isTrackingEnabled               | New features have been added.                                         |
  | createWebInterface           | -                               | Replaced with WebInterface related functions.                         |
  | -                            | createWebInterfaceScript        | New features have been added.                                         |
  | -                            | handleWebInterfaceCommand       | New features have been added.                                         |

  #### Constant (Cordova)

  | AirbridgeCategory (v2)  | AirbridgeCategory (v4)  | Change |
  | ----------------------- | ----------------------- | ------ |
  | SIGN\_UP                | SIGN\_UP                | -      |
  | SIGN\_IN                | SIGN\_IN                | -      |
  | SIGN\_OUT               | SIGN\_OUT               | -      |
  | HOME\_VIEWED            | HOME\_VIEWED            | -      |
  | PRODUCT\_LIST\_VIEWED   | PRODUCT\_LIST\_VIEWED   | -      |
  | SEARCH\_RESULTS\_VIEWED | SEARCH\_RESULTS\_VIEWED | -      |
  | PRODUCT\_VIEWED         | PRODUCT\_VIEWED         | -      |
  | ADD\_PAYMENT\_INFO      | ADD\_PAYMENT\_INFO      | -      |
  | ADD\_TO\_WISHLIST       | ADD\_TO\_WISHLIST       | -      |
  | ADD\_TO\_CART           | ADDED\_TO\_CART         | -      |
  | INITIATE\_CHECKOUT      | INITIATE\_CHECKOUT      | -      |
  | ORDER\_COMPLETED        | ORDER\_COMPLETED        | -      |
  | 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          | -      |

  | AirbridgeAttributes (v2)              | AirbridgeAttribute (v4)               | Change                                               |
  | ------------------------------------- | ------------------------------------- | ---------------------------------------------------- |
  | -                                     | ACTION                                | New features have been added.                        |
  | -                                     | LABEL                                 | New features have been added.                        |
  | -                                     | VALUE                                 | New features have been added.                        |
  | TOTAL\_VALUE                          | -                                     | The feature has been removed. Please enter in VALUE. |
  | CURRENCY                              | CURRENCY                              | -                                                    |
  | ORIGINAL\_CURRENCY                    | ORIGINAL\_CURRENCY                    | -                                                    |
  | PRODUCTS                              | PRODUCTS                              | -                                                    |
  | PERIOD                                | PERIOD                                | -                                                    |
  | IS\_RENEWAL                           | IS\_RENEWAL                           | -                                                    |
  | RENEWAL\_COUNT                        | RENEWAL\_COUNT                        | -                                                    |
  | PRODUCT\_LIST\_ID                     | PRODUCT\_LIST\_ID                     | -                                                    |
  | CART\_ID                              | CART\_ID                              | -                                                    |
  | TRANSACTION\_ID                       | TRANSACTION\_ID                       | -                                                    |
  | TRANSACTION\_TYPE                     | TRANSACTION\_TYPE                     | -                                                    |
  | TRANSACTION\_PAIRED\_EVENT\_CATEGORY  | TRANSACTION\_PAIRED\_EVENT\_CATEGORY  | -                                                    |
  | TRANSACTION\_PAIRED\_EVENT\_TIMESTAMP | TRANSACTION\_PAIRED\_EVENT\_TIMESTAMP | -                                                    |
  | TOTAL\_QUANTITY                       | TOTAL\_QUANTITY                       | -                                                    |
  | QUERY                                 | QUERY                                 | -                                                    |
  | IN\_APP\_PURCHASED                    | IN\_APP\_PURCHASED                    | -                                                    |
  | CONTRIBUTION\_MARGIN                  | CONTRIBUTION\_MARGIN                  | -                                                    |
  | ORIGINAL\_CONTRIBUTION\_MARGIN        | ORIGINAL\_CONTRIBUTION\_MARGIN        | -                                                    |
  | LIST\_ID                              | LIST\_ID                              | -                                                    |
  | RATE\_ID                              | RATE\_ID                              | -                                                    |
  | RATE                                  | RATE                                  | -                                                    |
  | MAX\_RATE                             | MAX\_RATE                             | -                                                    |
  | ACHIEVEMENT\_ID                       | ACHIEVEMENT\_ID                       | -                                                    |
  | SHARED\_CHANNEL                       | SHARED\_CHANNEL                       | -                                                    |
  | DATE\_TIME                            | DATE\_TIME                            | -                                                    |
  | DESCRIPTION                           | DESCRIPTION                           | -                                                    |
  | IS\_REVENUE                           | IS\_REVENUE                           | -                                                    |
  | PLACE                                 | PLACE                                 | -                                                    |
  | SCHEDULE\_ID                          | SCHEDULE\_ID                          | -                                                    |
  | TYPE                                  | TYPE                                  | -                                                    |
  | LEVEL                                 | LEVEL                                 | -                                                    |
  | SCORE                                 | SCORE                                 | -                                                    |
  | AD\_PARTNERS                          | AD\_PARTNERS                          | -                                                    |
  | IS\_FIRST\_PER\_USER                  | IS\_FIRST\_PER\_USER                  | -                                                    |

  | AirbridgeProduct (v2)   | AirbridgeAttribute (v4) | Change |
  | ----------------------- | ----------------------- | ------ |
  | PRODUCT\_ID             | PRODUCT\_ID             | -      |
  | PRODUCT\_NAME           | PRODUCT\_NAME           | -      |
  | PRODUCT\_PRICE          | PRODUCT\_PRICE          | -      |
  | PRODUCT\_QUANTITY       | PRODUCT\_QUANTITY       | -      |
  | PRODUCT\_CURRENCY       | PRODUCT\_CURRENCY       | -      |
  | PRODUCT\_POSITION       | PRODUCT\_POSITION       | -      |
  | PRODUCT\_CATEGORY\_ID   | PRODUCT\_CATEGORY\_ID   | -      |
  | PRODUCT\_CATEGORY\_NAME | PRODUCT\_CATEGORY\_NAME | -      |
  | PRODUCT\_BRAND\_ID      | PRODUCT\_BRAND\_ID      | -      |
  | PRODUCT\_BRAND\_NAME    | PRODUCT\_BRAND\_NAME    | -      |

  #### Function (iOS)

  | AirbridgeCO (v2)                 | AirbridgeCordova (v4) | Change                     |
  | -------------------------------- | --------------------- | -------------------------- |
  | getInstance                      | initializeSDK         | The name has been changed. |
  | deeplink.handleURLSchemeDeeplink | trackDeeplink         | The name has been changed. |
  | deeplink.handleUserActivity      | trackDeeplink         | The name has been changed. |

  #### Function (Android)

  | AirbridgeCO (v2)        | AirbridgeCordova (v4) | Change                     |
  | ----------------------- | --------------------- | -------------------------- |
  | init                    | initializeSDK         | The name has been changed. |
  | processDeeplinkData     | trackDeeplink         | The name has been changed. |
  | setLifecycleIntegration |                       | -                          |
</Accordion>

### SDK installation and initialization

The key values of airbridge.json have been changed. Change the key values as follows.

| airbridge.json (v2)             | airbridge.json (v4)                               |
| ------------------------------- | ------------------------------------------------- |
| trackingAuthorizeTimeoutSeconds | autoDetermineTrackingAuthorizationTimeoutInSecond |
| facebookDeferredAppLinkEnabled  | trackMetaDeferredAppLinkEnabled                   |
| sessionTimeoutSeconds           | sessionTimeoutInSecond                            |
| metaInstallReferrer             | metaInstallReferrerAppID                          |
| trackAirbridgeLinkOnly          | trackAirbridgeDeeplinkOnlyEnabled                 |
| userInfoHashEnabled             | hashUserInformationEnabled                        |
| sdkSignatureSecretID            | sdkSignatureID                                    |
| sdkSignatureSecret              | sdkSignatureSecret                                |

iOS

The `AirbridgeCO.getInstance` function in iOS has been replaced with the `AirbridgeCordova.initializeSDK` function. Modify the `ios/YOUR_PROJECT_NAME/AppDelegate.m` file.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- #import "AirbridgeCO.h"
- ...
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-     [AirbridgeCO getInstance:@"YOUR_APP_SDK_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
-     ...
- }
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+     [AirbridgeCordova initializeSDKWithName:@"YOUR_APP_NAME" token:@"YOUR_APP_SDK_TOKEN"];
+     ...
+ }
```

The `AirbridgeCO.init` function has been released with the `AirbridgeCordova.initializeSDK` function. Modify the `android/app/src/main/java/.../MainApplication.kt` file.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import co.ab180.airbridge.cordova.AirbridgeCO;
- ...
- @Override
- public void onCreate() {
-     super.onCreate();
-     AirbridgeCO.init(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN");
-     ...
- }
+ import co.ab180.airbridge.cordova.AirbridgeCordova;
+ ...
+ @Override
+ public void onCreate() {
+     super.onCreate();
+     AirbridgeCordova.initializeSDK(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN");
+     ...
+ }
```

### Deep Linking

The `Airbridge.setDeeplinkListener` function has been replaced with the `Airbridge.setOnDeeplinkReceived`function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- Airbridge.deeplink.setDeeplinkListener(function (deeplink) {
-     // show proper content
- });
+ Airbridge.setOnDeeplinkReceived(function (deeplink) {
+     // show proper content
+ });
```

The `AirbridgeCO.deeplink.handleURLSchemeDeeplink` , `AirbridgeCO.deeplink.handleUserActivity` functions in iOS has been replaced with the `AirbridgeCordova.trackDeeplink` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- #import "AirbridgeCO.h"
- ...
- (BOOL)application:(UIApplication *)application
-             openURL:(NSURL *)url
-             options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
- {
-   [AirbridgeCO.deeplink handleURLSchemeDeeplink:url];
-   return YES;
- }
- 
- -  (BOOL)application:(UIApplication *)application
- continueUserActivity:(NSUserActivity *)userActivity
-   restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
- {
-   [AirbridgeCO.deeplink handleUserActivity:userActivity];
-   return YES;
- }
+ @import Airbridge
+ ...
+ - (BOOL)application:(UIApplication *)application
+             openURL:(NSURL *)url
+             options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
+ {
+   [AirbridgeCordova trackDeeplinkWithUrl:url];
+   return YES;
+ }
+ 
+ -  (BOOL)application:(UIApplication *)application
+ continueUserActivity:(NSUserActivity *)userActivity
+   restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
+ {
+   [AirbridgeCordova trackDeeplinkWithUserActivity:userActivity];
+   return YES;
+ }
```

The `AirbridgeCO.processDeeplinkData` function has been replaced with the `AirbridgeCordova.trackDeeplink`function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import co.ab180.airbridge.cordova.AirbridgeCO;
- ...
- @Override
- protected void onResume() {
-   super.onResume();
-   AirbridgeCO.processDeeplinkData(getIntent());
- }
+ import co.ab180.airbridge.cordova.AirbridgeCordova;
+ ...
+ @Override
+ protected void onResume() {
+   super.onResume();
+   AirbridgeCordova.trackDeeplink(getIntent());
+ }
```

### In-app events and user data

<Danger>
  **Attention**
</Danger>

The `Airbridge.event.trackEvent` function has been deleted.

The parameters of the `Airbridge.trackEvent` function has been modified. The action, label, value parameters can be defined within the semanticAttributes.

Refer to the example codes below to use the `Airbridge.trackEvent` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- Airbridge.trackEvent('event', {
-     action: '...',
-     label: '...',
-     value: 100,
-     semanticAttributes: {
-         [AirbridgeAttributes.QUERY]: '...',
-     },
-     customAttributes: {
-         'key1': '...',
-         'key2': '...',
-         'key3': '...',
-     },
- })
+ Airbridge.trackEvent('event', {
+     [AirbridgeAttribute.ACTION]: '...',
+     [AirbridgeAttribute.LABEL]: '...',
+     [AirbridgeAttribute.VALUE]: 100,
+     [AirbridgeAttribute.QUERY]: '...',
+ }, {
+     'key1': '...',
+     'key2': '...',
+     'key3': '...',
+ })
```

<Danger>
  **Attention**

  The `action` , `label` , `value` , `semanticAttributes` values, which are in the second parameter of the `Airbridge.event.trackEvent` function must be included in the second parameter of the `Airbridge.trackEvent` function.

  The `customAttributes` value, which is the second parameter of the `Airbridge.event.trackEvent` function must be included in the third parameter of the `Airbridge.trackEvent` function.
</Danger>

The `Airbridge.state.setUser` , `Airbridge.state.updateUser` function has been replaced with [Airbridge.setUser](/en/developers/cordova-sdk-v4#send-additional-user-information) related functions. The `setUser` and `updateUser` functions have been deprecated.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- Airbridge.state.setUser({ ID: '...', email: '...' })
- Airbridge.state.updateUser({ phone: '...' })
+ Airbridge.setUserID('...')
+ Airbridge.setUserEmail('...')
+ Airbridge.setUserPhone('...')
```

### Additional settings

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

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- Airbridge.setAttribuitonListener((attribution) => {
-     // using attribution
- })
+ Airbridge.setOnAttributionReceived((attribution) => {
+     // using attribution
+ })
```

The `Airbridge.placement.click` , `Airbridge.placement.impression` functions have been replaced with the `Airbridge.click` , `Airbridge.impression` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- Airbridge.placement.click(url)
- Airbridge.placement.impression(url)
+ Airbridge.click(url)
+ Airbridge.impression(url)
```

The `Airbridge.createWebInterface` function has been replaced with the `Airbridge.createWebInterfaceScript` , `Airbridge.handleWebInterfaceCommand` functions.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- var inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
- inAppBrowserRef.addEventListener('loadstart', loadstartCallback);
- inAppBrowserRef.addEventListener('message', messageCallBack);
- const webInterface = Airbridge.createWebInterface(
-     'YOUR_WEB_TOKEN',
-     (function (arg) {
-         return `window.cordova_iab.postMessage(${arg})`;
-     })
- );
- function loadstartCallback(event) {
-     inAppBrowserRef.executeScript({ code : webInterface.script });
- }
- function messageCallBack(params){
-     webInterface.handle(JSON.stringify(params.data));
- }
+ const script = await Airbridge.createWebInterfaceScript(
+     'YOUR_WEB_TOKEN',
+     (function (arg) {
+         return `window.cordova_iab.postMessage(${arg})`;
+     })
+ );
+ var inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
+ inAppBrowserRef.addEventListener('loadstart', loadstartCallback);
+ inAppBrowserRef.addEventListener('message', messageCallBack);
+ function loadstartCallback(event) {
+     inAppBrowserRef.executeScript({ code : script });
+ }
+ function messageCallBack(params){
+     Airbridge.handleWebInterfaceCommand(JSON.stringify(params.data));
+ }
```

## Update within v2.x

See the major changes in each version of the Cordova-Ionic SDK.

### v2.6.0

For apps registered with Airbridge after September 4, 2023, the "airbridge\_referrer" will no longer be added to the deep link URL provided in the deep link callback. This issue was found in versions v2.5.0 to v2.5.2.

### v2.5.0

For apps registered with Airbridge after September 4, 2023, the "airbridge\_referrer" will no longer be added to the deep link URL provided in the deep link callback.

In the case of an iOS app update, the last calculated SKAdNetwork Conversion Value is finalized. No additional calculations are processed.

* In versions earlier than v2.5.1, the SKAdNetwork Conversion Value is only calculated for up to 24 hours.
* This does not affect users who newly installed the app.

`deeplink.page` has been deprecated. From v2.5.1, we recommend writing code using the deep link domain, `abr.ge`.

* `deeplink.page` will still be supported and functioning for backward compatibility.

### v2.4.0

The default value for `trackingAuthorizeTimeout` has been changed to 30 seconds.

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

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