SDK Migration - React Native SDK (v4)

    You'll find what you need to know about the process of updating the Airbridge React Native SDK. We recommend that you check everything from the current version onwards to the version after the update.

    Update from v2.x to v4.0

    Confirm once you update 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 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.

    The issue where the DeepLink URL provided in a DeepLink callback in Airbridge apps created after September 4, 2023, doubly decoded the contents entered in the Airbridge dashboard, has been resolved in versions v2.7.3 to v2.5.1.

    For Airbridge apps created after September 4, 2023, the DeepLink URL provided in the DeepLink callback no longer adds airbridge_referrer.

    If you update your iOS app, it becomes final with the last calculated SKAdNetwork Conversion Value, and it does not calculate additionally.

    • Versions under 2.5.1 calculate SKAdNetwork Conversion Value for only up to 24 hours.

    • This won't be a problem for newly installed users.

    deeplink.page has been deprecated. From 2.5.1 onwards, we recommend you create code using the DeepLink domain abr.ge.

    • deeplink.page is still supported and functions for backward compatibility.

    v2.5.0 - User privacy

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

    このページは役に立ちましたか?

    ご質問やご提案はありますか?