NowChatConfiguration을 전달하여 NowChat의 동작 수정
채팅 세션을 시작할 때 선택적 NowChatConfiguration 매개변수를 전달하여 NowChat의 일부 동작을 수정할 수 있습니다.
NowChatConfiguration 객체에는 다음 옵션이 포함됩니다.
- closePrompt: 채팅 창을 나가기 전에 나타나는 프롬프트 텍스트입니다. 다음 매개변수를 통해 이 프롬프트 텍스트를 정의합니다.
- header: 프롬프트의 헤더에 표시되는 Nullable 문자열 값입니다.
- message: 프롬프트의 본문에 표시되는 문자열 값입니다.
- acceptButtonTitle: 프롬프트의 기본 버튼에 표시되는 문자열 값입니다. 이 버튼을 누르면 채팅 창이 닫힙니다.
- declineButtonTitle: 프롬프트의 보조 버튼에 표시되는 문자열 값입니다. 이 버튼은 채팅 창을 닫지 않고 프롬프트를 해제합니다.
- disabledFeatures: 비활성화할 NowChat 기능 목록입니다. 비활성화할 수 있는 기능 목록은 NowChatConfiguration.Feature 열거형 클래스를 참조하십시오.
- conversationOptions: NowChat에 적용할 대화 옵션 목록입니다. 적용할 수 있는 옵션 목록은 NowChatConvestation.ConversationOption 열거형 클래스를 참조하십시오.
- uiConfiguration: NowChat에서 UI 구성요소를 구성하는 데 사용되는 UIConfiguration 값입니다.
다음 코드 예제는 NowChatConfiguration() 을 사용하여 NowChat을 구성하는 방법을 보여줍니다.
class MainActivity : AppCompatActivity() {
@Inject
lateinit var sdkManager: SdkManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//Drawable to use instead of the default NowChat back button.
val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)
val nowChatConfiguration = NowChatConfiguration(
closePrompt = NowChatConfiguration.ClosePrompt(
header = null,
message = "Are you sure you want to leave?",
acceptButtonTitle = "Yes",
declineButtonTitle = "No"
),
disabledFeatures = listOf(NowChatConfiguration.Feature.START_NEW_CONVERSATION),
conversationOptions = listOf(NowChatConfiguration.ConversationOption.FORCE_NEW_CONVERSATION),
uiConfiguration = NowChatConfiguration.UIConfiguration(
closeButton = NowChatConfiguration.CloseButton(
icon = myDrawable
),
attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)
)
)
//Start NowChat
lifecycleScope.launch {
sdkManager.getNowChatService()?.start(this@MainActivity, nowChatConfiguration = nowChatConfiguration)
}
}
}
자세한 내용은 해당 NowChatService - start(activity: Activity, themeColors: NowChatTheme = object: NowChatTheme{}, contextData: map<String, any> = mapOf(), chatConfiguration: NowChatConfiguration? = null)문서를 참조하십시오NowChatConfiguration - Android.