---
description: 캐시버튼 실행 방법에 대해 안내합니다.
---

# 캐시버튼 실행

{% hint style="info" %}
**LaunchChannelingBuilder를 사용하여, 캐시버튼 화면에 진입합니다.**

1. LaunchChannelingBuilder.Builder
2. builder instance → LaunchChannelingBuilder.Build
3. build callback → LaunchChannelingBuilder.LaunchView
{% endhint %}

<figure><img src="https://1192647449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdT8jjbnh8pMWsPV42jbV%2Fuploads%2FsyfYZ98zmY7JV5b7X7aL%2FCashButton_Launch.webp?alt=media&#x26;token=adb5707f-e1f2-4960-ad14-5bcca1f220b5" alt=""><figcaption></figcaption></figure>

***

## LaunchChannelingBuilder <a href="#launchchannelingbuilder.builder" id="launchchannelingbuilder.builder"></a>

### Builder(context, userID, birthday?, gender?)

{% hint style="info" %}
**2.0.0.213 버전부터 광고 물량 확대와 효율 향상을 위한 타겟팅 정보가 추가 되었습니다.**

**birthday, gender(옵션) 버전**
{% endhint %}

```kotlin
val builder = LaunchChannelingBuilder.Builder(
  context = androidContext,
  userID = channelingUserId,
  birthday = "1993-01-09",
  gender = UserGenderType.MALE
)
```

<table><thead><tr><th width="270">Name</th><th>Description</th></tr></thead><tbody><tr><td>context: Context</td><td>Android Context</td></tr><tr><td>userID: String</td><td>채널링 유저 키</td></tr><tr><td>birthday: String<strong>?</strong></td><td>채널링 회원 생년월일 (<strong>YYYY-MM-DD</strong>)</td></tr><tr><td>gender: UserGenderType<strong>?</strong></td><td><p>채널링 회원 성별</p><ul><li><code>UserGenderType.MALE</code>: 남자</li><li><code>UserGenderType.FEMALE</code>: 여자</li></ul></td></tr></tbody></table>

### Build(builderListener)

```kotlin
// Builder
val builder = LaunchChannelingBuilder.Builder(
  context = androidContext,
  userID = channelingUserId,
  birthday = "1993-01-09",
  gender = UserGenderType.MALE
)
// Build
builder.build(listener = object : LaunchChannelingBuilder.IBuilderListener {
  override fun onCompleted(builder: LaunchChannelingBuilder) {
    // 전달받은 LaunchChannelingBuilder를 통해 launchView() 호출 하여 캐시버튼 진입
  }
}
```

<details>

<summary><strong>IBuilderListener</strong></summary>

<pre class="language-kotlin"><code class="lang-kotlin"><strong>interface IBuilderListener {
</strong>    fun onCompleted(builder: LaunchChannelingBuilder)
}
</code></pre>

</details>

### LaunchView

**캐시버튼 화면에 진입 합니다.**

```kotlin
// Builder
val builder = LaunchChannelingBuilder.Builder(
  context = androidContext,
  userID = channelingUserId,
  birthday = "1993-01-09",
  gender = UserGenderType.MALE
)

// Build
builder.build(listener = object : LaunchChannelingBuilder.IBuilderListener {
  override fun onCompleted(builder: LaunchChannelingBuilder) {
    // 전달받은 LaunchChannelingBuilder를 통해 launchView() 호출 하여 캐시버튼 진입
    // Launch
    builder.launchView(ownerActivity = this@MainActivity, listener = object : ILaunchViewListener {
      override fun onLaunched(resultCode: Int) {
        // 1: 성공(정상)
        // -100: 이용약관 거절
        // -200: 유저타입 오류(캐시버튼 서버 설정 오류)
        // -201: 접근이 제한된 유저(인증을 통하지 않고 비정상 경로 접근)
        // -202: 탈퇴한 유저
        // -500: 서버 점검중
        // -800: SKProductType 설정 오류
        // -999: 서버 통신 오류 또는 알수 없는 오류
        Log.i("ChannelBuilder", "launchView::onLaunched { resultCode: $resultCode }")   
      }
    }
  }
}

// activity'onDestroy
override fun onDestroy() {
  // LaunchChannelingBuilder에서 사용되는 Dialog 종료 처리를 위한 호출
  LaunchChannelingBuilder.destroy()
  super.onDestroy()
}
```

| Name                          | Description       |
| ----------------------------- | ----------------- |
| ownerActivity: Activity       | Android Activity  |
| listener: ILaunchViewListener | LaunchView 결과 리스너 |

<details>

<summary><strong>ILaunchViewListener</strong></summary>

```kotlin
interface ILaunchViewListener {
    fun onLaunched(resultCode: Int)
}
```



</details>

| Result Code                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ul><li>1: 성공</li><li>-100: 실패 - 이용약관 거절</li><li>-200: 유저타입 오류</li><li>-201: 접근이 제한된 유저</li><li>-202: 탈퇴한 유저</li><li>-500: 서버 점검</li><li>-800: SKProduct 설정 오류</li><li>-999: 서버 통신 오류(&#x26; 알수없는 오류)</li></ul> |



