이 문서는 Adbrix Android SDK를 Android에 통합하는 방법을 다룹니다. Adbrix SDK를 설치하면 이벤트 분석 기능이 제공됩니다.
시작하기 전에
앱 생성
의 앱 설정/앱 정보
페이지에서 앱을 생성하여 SDK 초기화에 필요한 Application Key 와 Secret Key 를 발급받아 주십시오.
지원 정보
최소 지원 SDK : Android 4.4+ / API 19+
SDK 설치
의존성 추가하기
앱에서 Adbrix SDK의 의존성을 적용하려면 다음 단계를 완료하세요.
1. maven 의존성을 가져오기 위해 repositories 내에 mavenCentral
을 추가합니다.
Copy allprojects {
repositories {
mavenCentral()
}
}
Copy pluginManagement {
repositories {
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}
2. 앱의 모듈 디렉터리 내에 있는 build.gradle
파일을 엽니다.
Copy dependencies {
//Get the latest version from https://mvnrepository.com/artifact/com.igaworks.adbrix/android-sdk
implementation 'com.igaworks.adbrix:android-sdk:HERE_LATEST_VERSION'
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
}
Copy dependencies {
//Get the latest version from https://mvnrepository.com/artifact/com.igaworks.adbrix/android-sdk
implementation("com.igaworks.adbrix:android-sdk:HERE_LATEST_VERSION")
implementation("com.android.installreferrer:installreferrer:2.2")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
}
SDK 초기화
초기화 하기
앱에서 Adbrix SDK를 초기화하려면 다음 단계를 완료하세요.
1. Application을 상속한 객체를 생성합니다. 상속한 객체가 이미 있을 경우 해당 객체를 사용합니다.
Copy public class BaseApplication extends Application
Copy class BaseApplication: Application()
Copy @Override
public void onCreate() {
super.onCreate();
}
Copy override fun onCreate() {
super.onCreate()
}
3. onCreate() 메소드 내에 다음 코드를 작성합니다.
Copy Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}");
Copy Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}")
다음 코드 스니펫은 초기화 작성 완료 시의 예를 보여줍니다.
Copy public class BaseApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}");
}
}
Copy class BaseApplication: Application(){
override fun onCreate() {
super.onCreate()
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}")
}
}
4. AndroidManifest.xml에 작성한 Application을 등록합니다.
Copy <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name=".BaseApplication">
</application>
</manifest>
5. AndroidManifest.xml에 필요한 권한을 추가합니다.
Copy <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6. Proguard 설정
앱 최적화를 위해 Proguard를 사용하는 경우 Proguard가 클래스를 삭제하는 것을 방지하는 규칙을 추가해야 합니다.
Copy -keep class com.igaworks.adbrix.** { *; }
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }
7. 완료 되었습니다.
구글 광고 ID 설정하기
1. AndroidManifest.xml에 필요한 권한을 추가합니다.
Copy <uses-permission android:name="com.google.android.gms.permission.AD_ID" />
2. AdbrixConfig의 setCollectGoogleAdvertisingId(boolean isCollect)
메소드를 통해 광고 ID의 수집 여부를 변경합니다.
Copy AdbrixConfig config = new AdbrixConfig.Builder()
.setCollectGoogleAdvertisingId(true)
.build();
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config);
Copy val config = AdbrixConfig.Builder()
.setCollectGoogleAdvertisingId(true)
.build()
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config)
5. 완료 되었습니다.
딥링크 오픈 분석
딥링크 연동하기
딥링크 추적을 위해 딥링크로 인해 실행 될 Activity에 setIntent()
를 추가해주시기 바랍니다.
Copy @Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
Copy override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
}
지연된 딥링크 핸들링하기(선택사항)
SDK는 앱이 설치되지 않은 유저가 트랙킹 링크를 클릭 후 앱을 설치했을때 자동으로 딥링크를 실행합니다. 직접 지연된 딥링크를 핸들링 하려면 다음 메소드를 호출하여 자동 딥링크 실행을 막을 수 있습니다.
Copy blockDeferredDeepLinkLaunch(AdbrixDeferredDeepLinkListener listener): void
해당 메소드를 호출할 경우 지연된 딥링크의 경로로 Activity를 실행하지 않으므로 직접 구현해야합니다.
Copy Adbrix.getInstance().blockDeferredDeepLinkLaunch(new AdbrixDeferredDeepLinkListener() {
@Override
public void onDeferredDeepLinkReceived(Context context, AdbrixDeepLink adbrixDeepLink){
String deepLink = adbrixDeepLink.getDeepLink();
}
});
Copy Adbrix.getInstance().blockDeferredDeepLinkLaunch { context, adbrixDeepLink ->
val deepLink: String = adbrixDeepLink.deepLink
}
AdbrixDeepLink
result: ABDeepLinkResult
지연된 딥링크 처리 결과 입니다. ABDeepLinkResult 클래스로 해당 결과 값의 의미를 파악할수있습니다.
Copy adbrixDeepLink.getResult()
결과 값 의미
2 : TRACKING_LINK_SETTINGS_INCORRECTLY
3 : ORGANIC_NCPI_IN_PROCESS
deepLink : String
지연된 딥링크 값입니다.
Copy adbrixDeepLink.getDeepLink()
SDK 설정
SDK 초기화 시에 로그 활성화 등의 옵션을 설정할 수 있습니다.
로그 활성화 하기
로그 활성화는 Adbrix의 설정을 적용하는 AdbrixConfig를 사용하여 설정 가능합니다. AdbrixConfig는 init()
메소드 호출 시에 파라미터로 넣어 적용할 수 있습니다.
Copy setLogEnable(boolean enable)
첫 번째 인자인 enable
은 로그를 표시할지 말지 설정하는 값입니다. 기본값은 false
입니다.
BuildConfig.DEBUG
값을 넣어 디버그 모드일때만 로그가 출력 되고 배포시에는 출력되지 않게끔 설정할 수 있습니다.
Copy AdbrixConfig config = new AdbrixConfig.Builder()
.setLogEnable(true)
.build();
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config);
Copy val config = AdbrixConfig.Builder()
.setLogEnable(true)
.build()
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config)
로그 레벨 변경하기
로그 레벨은 Adbrix의 설정을 적용하는 AdbrixyConfig를 사용하여 설정 가능합니다. AdbrixConfig는 init()
메소드 호출 시에 파라미터로 넣어 적용할 수 있습니다.
Copy setLogLevel(int logLevel)
첫번째 인자인 logLevel
은 로그 표시 레벨을 설정하는 값입니다. 기본값은 Log.ERROR(6)
입니다.
Copy AdbrixConfig config = new AdbrixConfig.Builder()
.setLogLevel(Log.DEBUG)
.build();
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config);
Copy val config = AdbrixConfig.Builder()
.setLogLevel(Log.DEBUG)
.build()
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config)
구글 광고 ID 수집 여부 변경하기
Adbrix의 설정을 적용하는 AdbrixyConfig를 사용하여 구글 광고 ID의 수집 여부를 변경할 수 있습니다. AdbrixConfig는 init()
메소드 호출 시에 파라미터로 넣어 적용할 수 있습니다.
Copy setCollectGoogleAdvertisingId(boolean isCollect)
Copy AdbrixConfig config = new AdbrixConfig.Builder()
.setCollectGoogleAdvertisingId(true)
.build();
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config);
Copy val config = AdbrixConfig.Builder()
.setCollectGoogleAdvertisingId(true)
.build()
Adbrix.getInstance().init(this, "{YOUR_APPLICATION_KEY}", "{YOUR_SECRET_KEY}", config)
완료
SDK 설치 및 초기화가 완료되었습니다.