연동하기

이 문서는 Adbrix Flutter SDK를 앱에 통합하는 방법을 다룹니다. Adbrix SDK를 설치하면 이벤트 분석 기능이 제공됩니다.

시작하기 전에

앱 생성

Adbrix 콘솔앱 설정/앱 정보 페이지에서 앱을 생성하여 SDK 초기화에 필요한 Application KeySecret Key를 발급받아 주십시오.

앱 정보

지원 정보

Android

  • 최소 지원 SDK : Android 4.4+ / API 19+

  • Compile SDK : 35

iOS

  • iOS 12.0

  • Xcode 16.0

Flutter

  • Dart SDK 2.12.0+

  • Flutter SDK 1.20.0+

의존성

Android

SDK 설치

1. 터미널에서 Adbrix 패키지를 추가합니다.

다음의 명령어를 입력하여 프로젝트에 Adbrix Flutter SDK 패키지를 추가하세요. 그러면 pubspec.yaml 파일에 해당 줄이 추가됩니다.

flutter pub add adbrix_plugin

SDK 설정하기

AndroidManifest.xml 설정하기

1. <manifest> 내에 다음의 권한을 추가해주세요.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" /><!-- 구글 광고 ID를 수집해야할 경우 추가합니다. -->

2. 설정이 완료되었습니다.

다음은 작성이 완료된 예시입니다.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" /><!-- 구글 광고 ID를 수집해야할 경우 추가합니다. -->
    <application
        android:label="adbrix_plugin_example"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
    </queries>
</manifest>

SDK 초기화

초기화 하기

앱에서 Adbrix SDK를 초기화하려면 다음 단계를 완료하세요.

1. 스크립트에 Adbrix를 추가합니다.

import 'package:adbrix_plugin/adbrix_plugin.dart';

2. initState() 내에 다음 코드를 작성합니다.

Application KEY와 SECRET KEY는 Adbrix Console앱 설정 > 앱 정보에서 확인이 가능합니다.

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    Adbrix.init(applicationKey: "{YOUR_APPLICATION_KEY}", secretKey: "{YOUR_SECRET_KEY}");
  }

4. 초기화가 완료되었습니다.

구글 광고 ID 설정하기

Google 광고 ID를 수집하기 위해선 Config의 androidCollectGoogleAdvertisingIdtrue로 설정하여 수집 여부를 설정해야합니다. 만약 Google 광고ID를 수집하지 않아야 한다면, 구글 광고 ID 수집 여부 변경하기를 통해 수집하지 않도록 설정할 수 있습니다.

Map<String, dynamic> config = {
    ABConfig.androidCollectGoogleAdvertisingId: true
};
Adbrix.initWithConfig(applicationKey: "{YOUR_APPLICATION_KEY}", secretKey: "{YOUR_SECRET_KEY}", config: config);

딥링크 오픈 분석

Android

딥링크 정보를 가지고 있는 트래킹링크를 클릭하면 딥링크에 설정된 Activity가 실행됩니다. 딥링크가 정보가 없을 경우 android.intent.action.MAIN 액션을 가지고 있는 Activity가 실행됩니다.

Activity에 딥링크를 연동하는 방법은 Android에서 제공하는 앱 콘텐츠 딥링크 만들기를 참고하여 주시기 바랍니다.

iOS

iOS에서는 딥링크(Custom URL Schemes)유니버셜 링크(Universal Links)를 통해 앱을 열 수 있습니다. Adbrix SDK는 이러한 링크를 통한 앱 오픈을 분석합니다.

딥링크 연동하기

Android

딥링크 추적을 위해 딥링크로 인해 실행 될 Activity에 setIntent()를 추가해주시기 바랍니다.

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent); 
}

iOS

딥링크 추적을 위해 AppDelegate에 다음 코드를 추가해주시기 바랍니다.

import adbrix_plugin

override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    
    AdbrixPlugin.deepLinkOpen(url: url)
    
    return super.application(app, open: url, options: options)
}

override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
    
    AdbrixPlugin.deepLinkOpen(userActivity: userActivity)
    
    return super.application(application, continue: userActivity, restorationHandler: restorationHandler)
}

지연된 딥링크 핸들링하기(선택사항)

SDK는 앱이 설치되지 않은 유저가 트랙킹 링크를 클릭 후 앱을 설치했을때 자동으로 딥링크를 실행합니다. 직접 지연된 딥링크를 핸들링 하려면 다음 메소드를 호출하여 자동 딥링크 실행을 막을 수 있습니다.

Future<AdbrixDeepLinkCallback?> blockDeferredDeepLinkLaunch() async
Future<AdbrixDeepLinkCallback?> adbrixDeepLinkCallback = Adbrix.blockDeferredDeepLinkLaunch();
adbrixDeepLinkCallback.then((value) {
  if (value != null) {
    String deepLink = value.deepLink;
  }
}).catchError((error) {
  print("error in blockDeferredDeepLinkLaunch. ${error}");
});

AdbrixDeepLinkCallback

result: int

지연된 딥링크 처리 결과 입니다. ABDeepLinkResult 클래스로 해당 결과 값의 의미를 파악할수있습니다.

int result = value.result;
  • 결과 값 의미

    • 0 : PROCESSED

    • 1 : ORGANIC

    • 2 : TRACKING_LINK_SETTINGS_INCORRECTLY

    • 3 : ORGANIC_NCPI_IN_PROCESS

    • -1 : NO_CONVERSION

deepLink : String

지연된 딥링크 값입니다.

String deepLink = value.deepLink;

SDK 설정

SDK 초기화 시에 로그 활성화 등의 옵션을 설정할 수 있습니다.

로그 활성화 하기

플랫폼에 따라 ABConfig.iosLogEnable 혹은 ABConfig.androidLogEnable를 사용합니다.

Map<String, dynamic> config = {
  ABConfig.iosLogEnable: true,
  ABConfig.androidLogEnable: true
};
Adbrix.initWithConfig(applicationKey: "{YOUR_APPLICATION_KEY}", secretKey: "{YOUR_SECRET_KEY}", config: config);

로그 레벨 변경하기

ABConfig.androidLogLevel를 사용하여 로그 레벨 설정을 변경할 수 있습니다.

로그 레벨 값은 android.util.Log의 상수 값의 정의를 따릅니다.

Map<String, dynamic> config = {
  ABConfig.androidLogLevel: ABAndroidLogLevel.verbose
};
Adbrix.initWithConfig(applicationKey: "{YOUR_APPLICATION_KEY}", secretKey: "{YOUR_SECRET_KEY}", config: config);
  • ABAndroidLogLevel

    • VERBOSE : 2

    • DEBUG : 3

    • INFO : 4

    • WARN : 5

    • WARN : 6

    • ASSERT : 7

구글 광고 ID 수집 여부 변경하기

ABConfig.androidCollectGoogleAdvertisingId를 사용하여 Android 플랫폼에서 구글 광고 ID의 수집 여부를 변경할 수 있습니다.

Map<String, dynamic> config = {
    ABConfig.androidCollectGoogleAdvertisingId: true
};
Adbrix.initWithConfig(applicationKey: "{YOUR_APPLICATION_KEY}", secretKey: "{YOUR_SECRET_KEY}", config: config);

App Tracking Transparency (ATT) 지원

idfa 수집 가능 시점부터 SDK 이벤트를 수집하고 싶다면 다음 설정을 추가해주세요.

Map<String, dynamic> config = {
    ABConfig.iosTrackingTimeout: ABiOSTrackingTimeout.timeout60
};
Adbrix.initWithConfig(applicationKey: "{YOUR_APPLICATION_KEY}", secretKey: "{YOUR_SECRET_KEY}", config: config);

Adbrix.ATTAuthorized(bool isAuthorized) 메소드를 추적 허용 여부가 판단되는 시점에 호출해주세요.

다음은 permission_handler 패키지를 활용한 App Tracking Transparency (ATT) 구현 예시입니다.

Permission.appTrackingTransparency.request().then(value) {
  if (value.isGranted) {
    Adbrix.attAuthorized(authorized: true);
  } else {
    Adbrix.attAuthorized(authorized: false);
  }
});

완료

SDK 설치 및 초기화가 완료되었습니다.

Last updated