SDK Migration - Android SDK

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

    Update from v2.x to v4.0

    Check the information below when updating the Airbridge Android SDK to v4.0. All changes are listed.

    Airbridge Interface


    Summary

    Deprecated Interface

    Class changes


    Added

    Hidden

    Removed

    Moved

    AirbridgeOption


    SDK Initialization

    Airbridge.init(Application, AirbridgeConfig) has been changed to Airbridge.initializeSDK(Application, AirbridgeOption).

    AirbridgeConfig has been changed to AirbridgeOption. AirbridgeConfig.Builderhas been changed to AirbridgeOptionBuilder. Some function names in the AirbridgeOptionBuilder have been changed or deleted.

    Refer to the example below.

    123456
    override fun onCreate() {
        super.onCreate()
        val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
            .build()
        Airbridge.initializeSDK(this, option)
    }
    1234567
    @Override
    public void onCreate() {
        super.onCreate();
        AirbridgeOption option = new AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
            .build();
        Airbridge.initializeSDK(this, option);
    }

    The function name has been changed from getDeeplink() to handleDeeplink(). AirbridgeCallback has been removed. The OnSuccess and OnFailure listener have been added. You can check whether the function worked by its return value.

    12345
    val result = Airbridge.handleDeeplink(
        intent = intent
        onSuccess = { },
        onFailure = { }
    )
    12345
    boolean result = Airbridge.handleDeeplink(
            intent,
            uri -> { },
            throwable -> { }
    );

    We have improved the existing deferred deep link code logic that adds a listener to make screen transitions more convenient. The previous method of adding a listener has been removed. Instead, you can receive deferred deep links through the Airbridge interface.

    • You can call handleDeeplink and its value from the activity configuration.

    • You can check with the result value whether the deferred deep links can be handled.

    • Deferred deep links are designed to be acquired only once after the app install. If the value is already acquired or called first, the result is false.

    1234
    val result = Airbridge.handleDeferredDeeplink(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.handleDeferredDeeplink(
            uri -> { },
            throwable -> { }
    );

    Set up custom domain

    The method of specifying custom domain URLs in the res/values/airbridge.xml

    file, used in version 2.x, has been changed. You can now add custom domain links by using the setTrackingLinkCustomDomains function during Airbridge SDK initialization.

    1234567
    // YOUR_APP_NAME: input your app name
    // YOUR_APP_SDK_TOKEN: input your app token
    // YOUR_APP_CUSTOM_DOMAIN: input your app custom domain. ex) example.domain.com
    val option = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setTrackingLinkCustomDomains(listOf("YOUR_APP_CUSTOM_DOMAIN"))
        .build()
    Airbridge.initializeSDK(this, option)
    1234567
    // YOUR_APP_NAME: input your app name
    // YOUR_APP_SDK_TOKEN: input your app token
    // YOUR_APP_CUSTOM_DOMAIN: input your app custom domain. ex) example.domain.com
    AirbridgeOption option = new AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
        .setTrackingLinkCustomDomains(Arrays.asList("YOUR_APP_CUSTOM_DOMAIN"))
        .build();
    Airbridge.initializeSDK(this, option);

    In-app events and user data

    The following APIs have been deleted. Also, StandardEventCategory, SemanticAttributes, and Product have been removed.

    • trackEvent(category: StandardEventCategory, action: String? = null, label: String? = null, value: Number? = null, customAttributes: Map<String, Any?>? = null, semanticAttributes: Map<String, Any?>? = null)

    • trackEvent(category: String, action: String? = null, label: String? = null, value: Number? = null, customAttributes: Map<String, Any?>? = null, semanticAttributes: Map<String, Any?>? = null)

    • trackEvent(event: Event)

    New APIs have been added.

    • trackEvent(category: String, semanticAttributes: Map<String, Any>? = null, customAttributes: Map<String, Any>? = null)

    • AirbridgeCategory has been added. The event category string is predefined.

    • The function override and objects (SemanticAttributes, Product) for passing additional information were deleted.

    • Instead, it has been modified to transmit attributes through a map. The key value of the map is predefined in AirbridgeAttribute as a string. Custom attributes can be sent directly as a string.

    Refer to the AirbridgeCategory, AirbridgeAttribute mapping and trackEvent function below.

    123456789101112131415161718192021222324252627
    Airbridge.trackEvent(
        AirbridgeCategory.ORDER_COMPLETED,
        mapOf(
            // action
            AirbridgeAttribute.ACTION to "Tool",
            // label
            AirbridgeAttribute.LABEL to "Hammer",
            // value
            AirbridgeAttribute.VALUE to 10,
            // semantic attribute (provided by sdk)
            AirbridgeAttribute.CURRENCY to "USD",
            AirbridgeAttribute.PRODUCTS to listOf(
                mapOf(
                    // semantic attribute value (provided by sdk)
                    AirbridgeAttribute.PRODUCT_ID to "12345",
                    // semantic attribute value (not provided by sdk)
                    "name" to "PlasticHammer",
                ),
            ),
            // semantic attribute (not provided by sdk)
            "totalQuantity" to 1,
        ),
        mapOf(
            // custom attribute
            "promotion" to "FirstPurchasePromotion",
        )
    )
    12345678910111213141516171819202122232425262728
    Airbridge.trackEvent(
            AirbridgeCategory.ORDER_COMPLETED,
            new HashMap() {{
                // action
                put(AirbridgeAttribute.ACTION, "Tool");
                // label
                put(AirbridgeAttribute.LABEL, "Hammer");
                // value
                put(AirbridgeAttribute.VALUE, 10);
                // semantic attribute (provided by sdk)
                put(AirbridgeAttribute.CURRENCY, "USD");
                put(AirbridgeAttribute.PRODUCTS, Arrays.asList(
                    new HashMap() {{
                        // semantic attribute value (provided by sdk)
                        put(AirbridgeAttribute.PRODUCT_ID, "12345");
                        // semantic attribute value (not provided by sdk)
                        put("name", "PlasticHammer");
                    }}
                ));
                // semantic attribute (not provided by sdk)
                put("totalQuantity", 1);
                
            }},
            new HashMap() {{
                // custom attribute
                put("promotion", "FirstPurchasePromotion");
            }}
    );

    AirbridgeUser has been deleted. You can now access the interface through the Airbridge interface that was previously accessible through AirbridgeUser.

    Instead of accessing the code through Airbridge.getUserInfo(), you need to replace it with the following Airbridge interface.

    123456789101112131415161718
    fun setUserID(id: String)
    fun setUserEmail(email: String)
    fun setUserPhone(phone: String)
    
    fun setUserAttribute(key: String, value: Int)
    fun setUserAttribute(key: String, value: Long)
    fun setUserAttribute(key: String, value: Float)
    fun setUserAttribute(key: String, value: Double)
    fun setUserAttribute(key: String, value: Boolean)
    fun setUserAttribute(key: String, value: String)
    fun removeUserAttribute(key: String)
    fun clearUserAttributes()
    
    fun setUserAlias(key: String, value: String)
    fun removeUserAlias(key: String)
    fun clearUserAlias()
    
    fun clearUser()
    123456789101112131415161718
    void setUserID(String id)
    void setUserEmail(String email)
    void setUserPhone(String phone)
    
    void setUserAttribute(String key, int value)
    void setUserAttribute(String key, long value)
    void setUserAttribute(String key, float value)
    void setUserAttribute(String key, double value)
    void setUserAttribute(String key, boolean value)
    void setUserAttribute(String key, String value)
    void removeUserAttribute(String key)
    void clearUserAttributes()
    
    void setUserAlias(String key, String value)
    void removeUserAlias(key: String)
    void clearUserAlias()
    
    void clearUser()

    AirbridgeDeviceInfo has been deleted. The interface that was accessed through AirbridgeDeviceInfo has been modified so that it can now be accessed through the Airbridge interface.

    AirbridgeCallback has been deleted and OnSuccess, OnFailure listener has been added. You can receive the success status through this listener.

    You need to replace the codes that enables access through Airbridge.getDeviceInfo() with the following Airbridge interface.

    Device UUID

    1234
    val result = Airbridge.fetchDeviceUUID(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchDeviceUUID(
            uuid -> { },
            throwable -> { }
        );

    Install referrer

    fetch Google Install referrer

    1234
    val result = Airbridge.fetchGoogleInstallReferrerDetails(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchGoogleInstallReferrerDetails(
            referrerDetails -> { },
            throwable -> { }
    );

    fetch Huawei Install referrer

    1234
    val result = Airbridge.fetchHuaweiInstallReferrerDetails(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchHuaweiInstallReferrerDetails(
            referrerDetails -> { },
            throwable -> { }
        );

    fetch Galaxy store Install referrer

    1234
    val result = Airbridge.fetchGalaxyStoreInstallReferrerDetails(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchGalaxyStoreInstallReferrerDetails(
            referrerDetails -> { },
            throwable -> { }
        );

    fetch Meta Install referrer

    1234
    val result = Airbridge.fetchMetaInstallReferrerDetails(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchMetaInstallReferrerDetails(
            referrerDetails -> { },
            throwable -> { }
        );

    Advertising ID

    fetch Google Advertising ID

    1234
    val result = Airbridge.fetchGoogleAdvertisingIdInfo(
        onSuccess = { },
        onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchGoogleAdvertisingIdInfo(
            advertisingIdInfo -> { },
            throwable -> { }
        );

    fetch Huawei Advertising ID

    1234
    val result = Airbridge.fetchHuaweiAdvertisingIdInfo(
    	onSuccess = { },
    	onFailure = { }
    )
    1234
    boolean result = Airbridge.fetchHuaweiAdvertisingIdInfo(
            advertisingIdInfo -> { },
            throwable -> { }
        );

    AirbridgeDeviceInfo has been deleted. There is no function to receive the attribution result through the Airbridge interface. However, it can be received through the listener of AirbridgeOption, which is an existing method.

    123456789101112
    class App : Application() {
    
        override fun onCreate() {
            super.onCreate()
            val option: AirbridgeOption = AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
                .setOnAttributionReceived { result ->
                    // do something
                }
                .build()
            Airbridge.initializeSDK(this, option)
        }
    }
    123456789101112131415
    class App extends Application {
        
        @Override
        public void onCreate() {
            super.onCreate();
            
            Airbridge.initializeSDK(this,
                    new AirbridgeOptionBuilder("YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
                            .setOnAttributionReceived(result -> {
                                // do something
                            })
                            .build()
                    );
        }
    }

    AirbridgeCallback has been deleted and OnSuccess, OnFailure listeners have been added. You can check the operation status of the function through the return value.

    click

    12345
    fun click(
        trackingLink: String,
        onSuccess: OnSuccess<Unit>? = null,
        onFailure: OnFailure? = null
    ): Boolean
    12345
    boolean click(
        @NonNull String trackingLink,
        @Nullable OnSuccess<Unit> onSuccess,
        @Nullable OnFailure onFailure
    )

    impression

    12345
    fun impression(
        trackingLink: String,
        onSuccess: OnSuccess<Unit>? = null,
        onFailure: OnFailure? = null
    ): Boolean
    12345
    boolean impression(
        @NonNull String trackingLink,
        @Nullable OnSuccess<Unit> onSuccess,
        @Nullable OnFailure onFailure
    )

    Hybrid app integration

    The function name has been changed from setJavascriptInterface() to setWebInterface().

    1
    Airbridge.setWebInterface(webview, "YOUR_WEB_TOKEN")
    1
    Airbridge.setWebInterface(webview, "YOUR_WEB_TOKEN")

    Update within v2.x

    This section describes the major changes in each version of the Android SDK.

    v2.24.0

    For apps registered with Airbridge after September 4, 2023, we’ve resolved the issue where the deep-link URL provided in the deep-link callback was decoding the content entered in the Airbridge dashboard twice.

    This issue occurred in Android SDK from v2.22.0 to v2.23.0.

    v2.21.2

    An initialization option has been added to stop sending events when the app is in the background.

    • You can use the AirbridgeConfig#setTransmitEventOnBackgroundEnabledfunction to stop sending events when the app is in the background.

    • The default value is true. When true, the remaining events are sent even when the app is in the background.

    v2.21.1

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

    deeplink.page is still supported and operates for backward compatibility.

    v2.19.1

    • Changes have been made so that ORGANIC_REOPEN, FOREGROUND events that occur within the session time are not collected by default.

    • BACKGROUND events have been removed.

    v2.18.0

    Deeplink Pageview events will only be collected when Airbridge.click is called.