SDK Migration - React Native SDK (v4)

    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.

    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.

    123456789101112
    - 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.

    1234567891011121314
    - 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")
    +     ...
    + }

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

    12345678910
    - 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.

    12345678910111213141516171819202122232425262728293031323334
    - 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.

    123456789101112
    - 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)
    + }

    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.

    123456789101112131415161718192021222324252627
    - 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': '...',
    + })

    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.

    The functions Airbridge.state.setUser and Airbridge.state.updateUser have been replaced with the Airbridge.setUser related functions. The setUser , updateUser functions, which set user information all at once, are no longer supported.

    123456789
    - 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.

    12345678910
    - 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.

    12345678
    - 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.

    12345678910111213141516171819202122
    - 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.

    For Airbridge Apps created after September 4, 2023, an issue where the deep link URL provided in the deep link callback was decoded twice from the content entered in the Airbridge dashboard has been resolved. This issue was found in versions v2.7.3 to v2.5.1.

    For Airbridge Apps created 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.

    Was this page helpful?

    Have any questions or suggestions?