NowChatService 클래스 - Android
NowChatService 클래스는 NowChat 활동을 시작하고 오류 구성을 설정하는 데 사용할 수 있는 함수를 제공합니다.
NowChatService - launchIntent(context:Context, themeColors:NowChatTheme):Intent
NowChat 활동을 여는 데 사용되는 의도를 시작합니다. 일반적으로 [android.app.PendingIntent]를 만드는 데 사용됩니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 컨텍스트 | 컨텍스트 | 의도를 작성하는 데 사용되는 컨텍스트입니다. |
| 테마색상 | 나우챗테마 | 옵션입니다. NowChat UI에서 사용할 테마 색상입니다. 기본값: 기본 색상 |
| 유형 | 설명 |
|---|---|
| 의도 | 연결된 NowChat 활동을 시작하는 데 사용되는 의도 및 테마 색상입니다. |
이 예제에서는 launchIntent() 메서드를 호출하고 return 활동을 처리하는 방법을 보여 줍니다.
val intent = nowChatService.launchIntent(this)
val pendingIntent = PendingIntent.getActivity(
this,
REQUEST_CODE,
intent,
PendingIntent.FLAG_IMMUTABLE
)
val notification = createNotification(title, message, pendingIntent)
notificationManager.notify(push.notificationId, notification)
NowChatService - start(activity: Activity, themeColors: NowChatTheme = object : NowChatTheme{})
지정된 NowChat 활동을 시작합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 활동 | 활동 | NowChat 활동을 시작하고 onActivityResult를 통해 결과 코드로 NowChatExitCode를 수신하는 데 사용할 활동 컨텍스트입니다. |
| 테마색상 | 나우챗테마 | 옵션입니다. NowChat UI에서 사용할 테마 색상입니다. 기본값: 기본 색상 |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.
lifecycleScope.launch {
sdkManager.getNowChatService()?.start(this@MainActivity, object : NowChatTheme {
override val brand: NowUIAdaptiveColor
// Setting lightColor only. For dark theme default color will be used
get() = NowUIAdaptiveColor(lightColor = Color.BLACK)
override val primary: NowUIAdaptiveColor
// Setting both lightColor and darkColor
get() = NowUIAdaptiveColor(lightColor = Color.BLACK, darkColor = Color.WHITE)
// Override the rest of color variables
})
}
NowChatService - subscribeToUnreadMessageCount(pollingInterval: Long, 수신기: NowChatUnreadMessagesCountListener)
읽지 않은 채팅 메시지 카운트 수신기를 구독합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| pollingInterval | 길게 | 읽지 않은 채팅 메시지 수에 대해 웹 서비스를 폴링할 빈도입니다. 단위: 밀리초 |
| 수신기 | NowChatUnreadMessagesCountListener | 읽지 않은 채팅 메시지 수를 얻기 위해 구현하는 수신기입니다. 또한 메서드를 사용하여 NowChatService - unsubscribeFromUnreadMessageCount(listener: NowChatUnreadMessagesCountListener) 읽지 않은 메시지 수를 더 이상 가져오지 않으려는 경우 이 수신기를 구독 취소해야 합니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 예제에서는 채팅 읽지 않은 메시지 카운트 수신기를 구독 및 구독 취소하는 방법을 보여 줍니다.
private val unreadMessageCountListener = object: NowChatUnreadMessagesCountListener {
override fun unreadMessagesCountDidChange(unreadMessageCount: Int) {
}
}
fun setup() {
nowChatService.subscribeToUnreadMessageCount(pollingInterval:1000, unreadMessageCountListener)
}
fun teardown() {
nowChatService.unsubscribeFromUnreadMessageCount(unreadMessageCountListener)
}
NowChatService - unsubscribeFromUnreadMessageCount(listener: NowChatUnreadMessagesCountListener)
읽지 않은 메시지 수 수신을 구독 취소합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 수신기 | NowChatUnreadMessagesCountListener | 채팅 읽지 않은 메시지 카운트 수신기에서 구독을 취소하기 위해 구현하는 수신기입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 예제에서는 채팅 읽지 않은 메시지 카운트 수신기를 구독 및 구독 취소하는 방법을 보여 줍니다.
private val unreadMessageCountListener = object: NowChatUnreadMessagesCountListener {
override fun unreadMessagesCountDidChange(unreadMessageCount: Int) {
}
}
fun setup() {
nowChatService.subscribeToUnreadMessageCount(pollingInterval:1000, unreadMessageCountListener)
}
fun teardown() {
nowChatService.unsubscribeFromUnreadMessageCount(unreadMessageCountListener)
}