> ## 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 - React Native SDK

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

## Update from v2.x to v4.0

Check the information below when updating the Airbridge React Native SDK to v4.0.

<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 (React Native)

  | 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 (React Native)

  | 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)

  | AirbridgeRN (v2)                 | AirbridgeReactNative (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)

  | AirbridgeRN (v2)        | AirbridgeReactNative (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                                |

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

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

The `AirbridgeRN.init` function in Android has been replaced with the `AirbridgeReactNative.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.reactnative.AirbridgeRN;
- ...
- override fun onCreate() {
-     super.onCreate()
-     AirbridgeRN.init(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
-     ...
- }
+ import co.ab180.airbridge.reactnative.AirbridgeReactNative
+ ...
+ override fun onCreate() {
+     super.onCreate()
+     AirbridgeReactNative.initializeSDK(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
+     ...
+ }
```

### Deep Link

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

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import Airbridge from 'airbridge-react-native-sdk'
- ...
- Airbridge.setDeeplinkListener((url) => {
-     // show proper content
- })
+ import { Airbridge } from 'airbridge-react-native-sdk'
+ ...
+ Airbridge.setOnDeeplinkReceived((url) => {
+     // show proper content
+ })
```

In iOS, the `AirbridgeRN.deeplink.handleURLSchemeDeeplink` , `AirbridgeRN.deeplink.handleUserActivity` functions have been replaced with the `AirbridgeReactNative.trackDeeplink` function.

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

In Android, the `AirbridgeRN.deeplink.processDeeplinkData` function have been replaced with the `AirbridgeReactNative.trackDeeplink` function.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import co.ab180.airbridge.reactnative.AirbridgeRN
- ...
- override fun onResume() {
-   super.onResume()
-   AirbridgeRN.processDeeplinkData(intent)
- }
+ import co.ab180.airbridge.reactnative.AirbridgeReactNative
+ ...
+ override fun onResume() {
+   super.onResume()
+   AirbridgeReactNative.trackDeeplink(intent)
+ }
```

### Set up custom domain

The method of specifying custom domain URLs in used in version 2.x, has been changed. You can now add custom domain links to the `trackingLinkCustomDomains`in the airbridge.json during Airbridge SDK initialization.

```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
{
    "trackingLinkCustomDomains": ["YOUR_APP_CUSTOM_DOMAIN"]
}
```

### In-app events and user data

The function Airbridge.event.trackEvent has been replaced with Airbridge.trackEvent.

Please change the function Airbridge.event.trackEvent to Airbridge.trackEvent following the example code below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import Airbridge, { AirbridgeAttributes } from 'airbridge-react-native-sdk'
- ...
- Airbridge.event.trackEvent('event', {
-     action: '...',
-     label: '...',
-     value: 100,
-     semanticAttributes: {
-         [AirbridgeAttributes.QUERY]: '...',
-     },
-     customAttributes: {
-         'key1': '...',
-         'key2': '...',
-         'key3': '...',
-     },
- })
+ import { Airbridge, AirbridgeAttribute } from 'airbridge-react-native-sdk'
+ ...
+ 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 functions `Airbridge.state.setUser` and `Airbridge.state.updateUser` have been replaced with the [Airbridge.setUser](/en/developers/react-native-sdk-v4#set-additional-user-information) related functions. The `setUser` , `updateUser` functions, which set user information all at once, are no longer supported.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import Airbridge from 'airbridge-react-native-sdk'
- ...
- Airbridge.state.setUser({ ID: '...', email: '...' })
- Airbridge.state.updateUser({ phone: '...' })
+ import { Airbridge } from 'airbridge-react-native-sdk'
+ ...
+ 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"}}
- import Airbridge from 'airbridge-react-native-sdk'
- ...
- Airbridge.setAttribuitonListener((attribution) => {
-     // using attribution
- })
+ import { Airbridge } from 'airbridge-react-native-sdk'
+ ...
+ Airbridge.setOnAttributionReceived((attribution) => {
+     // using attribution
+ })
```

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

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- import Airbridge from 'airbridge-react-native-sdk'
- ...
- Airbridge.placement.click(url)
- Airbridge.placement.impression(url)
+ import { Airbridge } from 'airbridge-react-native-sdk'
+ ...
+ 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"}}
- import Airbridge from 'airbridge-react-native-sdk'
- ...
- const { script, handle } = Airbridge.createWebInterface(
-     'YOUR_WEB_TOKEN',
-     (command) => { 
-         return `window.ReactNativeWebView.postMessage(${command})`
-     },
- )
- <WebView
-     source={{ uri: 'https://...' }}
-     onMessage={(command) => { handle(command) }}
-     injectedJavaScript={script} />
+ import { Airbridge } from 'airbridge-react-native-sdk'
+ ...
+ const script = await Airbridge.createWebInterface(
+     'YOUR_WEB_TOKEN',
+     'window.ReactNativeWebView.postMessage(payload)',
+ )
+ <WebView
+     source={{ uri: 'https://...' }}
+     onMessage={(command) => { Airbridge.handleWebInterfaceCommand(command) }}
+     injectedJavaScript={script} />
```

## Update within v2.x

See the major changes in each version of the React Native SDK.

### v2.8.0 - Deep Link

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.7.3 to v2.5.1.

### v2.5.1 - Deep Link

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.5.0 - User privacy

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-react-native-sdk-v4" />

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