SDK Migration - Flutter SDK (v4)

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

    Update from v3.x to v4.0

    Check the information below after updating the Airbridge Flutter SDK to v4.0.

    SDK installation and initialization

    The location of airbridge.json has been changed. Move the assets/airbridge.json file to the airbridge.json file at the top of the Flutter project folder.

    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 AirbridgeFlutter.init function in iOS has been replaced with the AirbridgeFlutter.initializeSDK function. Modify the ios/YOUR_PROJECT_NAME/AppDelegate.swift file.

    12345678910111213141516171819
    - override func application(
    -     _ application: UIApplication,
    -     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    - ) -> Bool {
    -     AirbridgeFlutter.init(
    -         appName: "YOUR_APP_NAME",
    -         appToken: "YOUR_APP_SDK_TOKEN",
    -         withLaunchOptions: launchOptions
    -     )
    - }
    + override func application(
    +     _ application: UIApplication,
    +     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    + ) -> Bool {
    +     AirbridgeFlutter.initializeSDK(
    +         name: "YOUR_APP_NAME",
    +         token: "YOUR_APP_SDK_TOKEN",
    +     )
    + }

    The AirbridgeFlutter.init function in Android has been replaced with the AirbridgeFlutter.initializeSDK function. Modify the android/app/src/main/java/.../MainApplication.kt file.

    1234567891011121314
    - import co.ab180.airbridge.flutter.AirbridgeFlutter
    - ...
    - override fun onCreate() {
    -     super.onCreate()
    -     AirbridgeFlutter.init(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
    -     ...
    - }
    + import co.ab180.airbridge.flutter.AirbridgeFlutter
    + ...
    + override fun onCreate() {
    +     super.onCreate()
    +     AirbridgeFlutter.initializeSDK(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
    +     ...
    + }

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

    12345678910
    - import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    - ...
    - Airbridge.setDeeplinkListener((url) => {
    -     // show proper content
    - })
    + import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    + ...
    + Airbridge.setOnDeeplinkReceived((url) => {
    +     // show proper content
    + })

    In iOS, the AirbridgeFlutter.deeplink.handleURLSchemeDeeplink and the AirbridgeFlutter.deeplink.handleUserActivity functions have been replaced with the AirbridgeFlutter.trackDeeplink function.

    123456789101112131415161718192021222324252627282930
    - override func application(
    -     _ application: UIApplication,
    -     continue userActivity: NSUserActivity,
    -     restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
    - ) -> Bool {
    -     AirbridgeFlutter.deeplink.handle(userActivity)
    -     
    -     return true
    - }
    - 
    - override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    -     AirbridgeFlutter.deeplink.handleURLSchemeDeeplink(url)
    -     
    -     return true
    - }
    + override func application(
    +     _ application: UIApplication,
    +     continue userActivity: NSUserActivity,
    +     restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
    + ) -> Bool {
    +     AirbridgeFlutter.trackDeeplink(userActivity: userActivity)
    +     
    +     return true
    + }
    + 
    + override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    +     AirbridgeFlutter.trackDeeplink(url: url)
    +     
    +     return true
    + }

    In Android, the AirbridgeFlutter.processDeeplinkData function has been replaced with the AirbridgeFlutter.trackDeeplink function.

    123456789101112
    - import co.ab180.airbridge.flutter.AirbridgeFlutter
    - ...
    - override fun onResume() {
    -   super.onResume()
    -   AirbridgeFlutter.processDeeplinkData(intent)
    - }
    + import co.ab180.airbridge.flutter.AirbridgeFlutter
    + ...
    + override fun onResume() {
    +   super.onResume()
    +   AirbridgeFlutter.trackDeeplink(intent)
    + }

    In-app events and user data

    Attention

    Please input the value into AirbridgeAttribute.VALUE instead of the existing AirbridgeAttributes.TOTAL_VALUE.

    If you're using AirbridgeAttributes.TOTAL_VALUE and defining a value, the logic that AirbridgeAttributes.TOTAL_VALUE overwrites the value has been removed from Flutter SDK v4 onwards.

    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.

    1234567891011121314151617181920212223242526272829303132
    - import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    - ...
    - Airbridge.event.trackEvent(
    -     'event',
    -     AirbridgeEventOption(
    -         action: '...',
    -         label: '...',
    -         value: 100,
    -         semanticAttributes: {
    -             AirbridgeAttributes.QUERY: '...',
    -         },
    -         customAttributes: {
    -             'key1': '...',
    -             'key2': '...',
    -             'key3': '...',
    -         },
    -     ));
    + import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    + ...
    + Airbridge.trackEvent(
    +     category: 'event',
    +     semanticAttributes: {
    +         AirbridgeAttribute.ACTION: '...',
    +         AirbridgeAttribute.LABEL: '...',
    +         AirbridgeAttribute.VALUE: 100,
    +         AirbridgeAttribute.QUERY: '...',
    +     },
    +     customAttributes: {
    +             '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.

    12345678910111213141516
    - import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    - ...
    - Airbridge.state.setUser(
    -     User(
    -         id: '...',
    -         email: '...'
    -     ));
    - Airbridge.state.updateUser(
    -     User(
    -         phone: '...'
    -     ));
    + import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    + ...
    + Airbridge.setUserID('...')
    + Airbridge.setUserEmail('...')
    + Airbridge.setUserPhone('...')

    Additional settings

    The Airbridge.setAttributionListener function has been replaced with the Airbridge.setOnAttributionReceived function.

    12345678910
    - import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    - ...
    - Airbridge.setAttributionListener((attribution) {
    -     // using attribution
    - });
    + import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    + ...
    + 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 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    - ...
    - Airbridge.placement.click(url);
    - Airbridge.placement.impression(url);
    + import 'package:airbridge_flutter_sdk/airbridge_flutter_sdk.dart';
    + ...
    + Airbridge.click(url);
    + Airbridge.impression(url);

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

    123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
    - var webInterface = Airbridge.createWebInterface(
    -     webToken: 'YOUR_WEB_TOKEN',
    -     postCommandFunction: (arg) {
    -       return """window.flutter_inappwebview.callHandler('postMessage', $arg);"""; 
    -   });
    - ...
    - InAppWebView(
    -   initialUrlRequest: URLRequest(url: WebUri('https://...')),
    -   onWebViewCreated: (controller) async {
    -     controller.addJavaScriptHandler(handlerName: 'postMessage', callback: (args) {
    -       webInterface.handle(args[0]);
    -       return args;
    -     });
    -   },
    -   initialUserScripts: UnmodifiableListView<UserScript>([
    -     UserScript(
    -       source: webInterface.script, 
    -       injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START)
    -   ]),
    -   ...
    - )
    - ...
    + Future<String?> getJavascriptInterface() async {
    +     return await Airbridge.createWebInterfaceScript(
    +       webToken: 'YOUR_WEB_TOKEN',
    +       postMessageScript: 'window.flutter_inappwebview.callHandler(payload);',
    +     );
    +   }
    + ...
    + FutureBuilder(
    +   future: getJavascriptInterface(),
    +   builder: (BuildContext context, AsyncSnapshot snapshot) {
    +     return 
    +       ...
    +       InAppWebView(
    +         initialUrlRequest: URLRequest(url: WebUri('https://...')),
    +         onWebViewCreated: (controller) async {
    +           controller.addJavaScriptHandler(handlerName: 'postMessage', callback: (args) {
    +             Airbridge.handleWebInterfaceCommand(args[0]);
    +             return args;
    +           });
    +         },
    +         initialUserScripts: UnmodifiableListView<UserScript>([
    +           UserScript(
    +             source: snapshot.data ?? "", 
    +             injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START)
    +         ]),
    +       )
    +       ...
    +   });
    + ...

    Update within v3.x

    See the major changes in each version of the Flutter 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 v3.4.2 to v3.4.7.

    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 v3.4.2, 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 v3.4.2, we recommend writing code using the deep link domain, abr.ge.

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

    v3.4.1 - kotlin

    The Kotlin plugin version has been updated to 1.5.21.

    v3.4.0 - User privacy

    The default value of "trackingAuthorizeTimeout" has been changed to 30 seconds.

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

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