SDK 초기화
이 단계에서는 Application 레벨에서 SDK 이벤트 리스너를 등록하고 echoCode를 설정하는 SDK 동작 준비 과정에 대해 설명합니다.
목표
- 1.
PlengiListener구현 - 2.
echoCode설정 - 3.
Application에 리스너 등록
PlengiListener 구현
PlengiListener 에서 다음 SDK 이벤트를 수신합니다.
위치 요청 결과
info
PlengiResponse에 대한 자세한 내용은 위치 요청 결과 레퍼런스에서 확인하실 수 있습니다.
캠페인 매칭 결과
PlengiResponse.Advertisement에 캠페인 매칭 정보가 있습니다.
info
캠페인 매칭 정보는 loplat X를 사용하는 경우에만 사용할 수 있습니다.
Advertisement에 대한 자세한 내용은 캠페인 매칭 결과 레퍼런스에서 확인하실 수 있습니다.
생성 예시
- Java
- Kotlin
public class LoplatPlengiListener implements PlengiListener {
@Override
public void listen(PlengiResponse response) {
if (response.result == PlengiResponse.Result.SUCCESS) {
// response.place, response.area, response.complex 등 사용
} else {
// response.errorReason 확인
}
}
}
class LoplatPlengiListener : PlengiListener {
override fun listen(response: PlengiResponse) {
if (response.result == PlengiResponse.Result.SUCCESS) {
// response.place, response.area, response.complex 등 사용
} else {
// response.errorReason 확인
}
}
}
echoCode 설정
echoCode는 로플랫과 데이터 연동 시 고객사에서 분석과 조회하기 위한 사용자 식별 코드입니다.
"echoCode에는 개인정보가 포함되면 안됩니다."
이메일, 전화번호와 같은 개인정보 혹은 광고 ID(ADID, IDFA)를 전달하지 마세요.
info
start() 후에 설정할 경우 데이터 분석 시 누락이 발생할 수 있습니다. start() 전에 설정하는 것을 권장합니다.
- Java
- Kotlin
Plengi.getInstance(this).setEchoCode("[ECHO_CODE]");
Plengi.getInstance(this).setEchoCode("[ECHO_CODE]")
Application에서 등록
반드시 Application.onCreate() 에서 등록해 주세요.
info
만약 Application이 없다면 생성 후 AndroidManifest.xml 에 추가해 주세요.
<application
android:name=".LoplatSampleApplication"
... />
완성된 Application 예시
- Java
- Kotlin
public class LoplatSampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Plengi.getInstance(this).setListener(new LoplatPlengiListener());
Plengi.getInstance(this).setEchoCode("[ECHO_CODE]");
}
}
class LoplatSampleApplication : Application() {
override fun onCreate() {
super.onCreate()
Plengi.getInstance(this).setListener(LoplatPlengiListener())
Plengi.getInstance(this).setEchoCode("[ECHO_CODE]")
}
}