NowChatServiceDelegate 프로토콜 - iOS
NowChatServiceDelegate 프로토콜은 URL 열기 요청 또는 채팅 뷰 컨트롤러 해제 등 NowChatService 내의 작업 알림에 대한 콜백을 제공합니다.
NowChatServiceDelegate - chatService(_chatService: NowChatService, didRequestOpenUrlurl: URL)
지정된 채팅 서비스가 URL 열기 요청을 받았음을 호스트 애플리케이션에 알리는 콜백입니다. 이 콜백은 일반적으로 사용자가 채팅 UI의 링크를 탭하여 트리거됩니다. URL 열기를 처리하거나 요청을 무시하는 것은 호스트 응용 프로그램의 책임입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 채팅 서비스 | 나우챗서비스 | 요청을 하는 NowChatService 객체입니다. |
| didRequestOpenUrl URL | URL | 서비스가 열도록 요청한 URL입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.
func chatService(_ chatService: NowChatService, didRequestOpenUrl url: URL) {
var updatedViewState = makeViewState()
updatedViewState.urlToOpen = url
viewState = updatedViewState
}
NowChatServiceDelegate - chatService(_ chatService: NowChatService, systemThemeDidChange traitCollection: UITraitCollection)
시스템 채팅 테마가 변경되었음을 호스트 애플리케이션에 알리는 콜백입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 채팅 서비스 | 나우챗서비스 | 요청을 하는 NowChatService 객체입니다. |
| 트레이트컬렉션 | UITrait컬렉션 | UITraitCollection 새 테마가 포함되어 있습니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 코드 예제에서는 systemThemeDidChange() 대리자 함수를 재정의하여 updateTheme() 함수를 호출하여 시스템 테마가 변경될 때 테마 변경 사항을 적용하는 방법을 보여 줍니다.
func chatService(_ chatService: any SnowChat.ChatServiceProvider, systemThemeDidChange traitCollection: UITraitCollection) {
/// The corresponding updateTheme() method can be called here to change the UI theme based on System Theme
chatService.updateTheme(theme: traitCollection.userInterfaceStyle == .dark ? DarkNowChatTheme() : LightNowChatTheme())
print(“System Theme Did Change)
}
NowChatServiceDelegate - chatServiceViewControllerWasDismissed(_chatService: NowChatService)
채팅 뷰 컨트롤러가 해제되었음을 호스트 애플리케이션에 알리는 콜백입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 채팅 서비스 | 나우챗서비스 | 뷰 컨트롤러가 해제된 NowChatService 객체입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.
func chatServiceViewControllerWasDismissed(_ chatService: NowChatService) {
resetChat()
}
NowChatServiceDelegate - didEndSessionWithId(sessionId: 문자열)
채팅 화면이 닫히고 채팅 세션이 종료될 때 호출됩니다.
주:
함수를 재정의하여 이 콜백에 대해 원하는 기능을 정의할 수 있습니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| sessionId | 문자열 | 종료된 세션의 Sys_id입니다. 테이블: 대화 세션 [sys_cs_session] |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 코드 예제에서는 기본 기능을 재정의하기 위해 코드를 배치할 위치를 보여 줍니다.
func chatService(_ chatService: NowChatService, didEndSessionWithId sessionId: String) {
print("Chat Session ended with ID: \(sessionId)")
}