NowChatConfiguration: iOS
NowChatConfiguration クラスを使用すると、チャットウィンドウを閉じる前にプロンプトを表示する、チャットの使用中に機能を無効にする、チャットを使用するときにさまざまな会話オプションを適用する、NowChat で UI コンポーネントを設定するなど、チャットセッションのオプションを設定できます。
NowChatConfiguration:NowChatConfiguration(closePrompt: ClosePrompt?, disabledFeatures: [Feature]? = nil, conversationOptions: [ConversationOption]? = nil, uiConfiguration: UIConfiguration? = nil)
現在のチャットセッションのオプションを設定します。この方法を使用すると、チャットウィンドウを閉じる前にプロンプトを表示したり、チャットの使用中に機能を無効にしたり、チャットの使用時にさまざまな会話オプションを適用したり、NowChat で UI コンポーネントを設定したりできます。
| 名前 | タイプ | 説明 |
|---|---|---|
| プロンプトを閉じる | ClosePrompt? | 関連するチャットウィンドウを閉じる前に表示するプロンプト。 NowChatConfiguration.ClosePrompt() 構造体を呼び出して、このパラメーターの値を定義します。 例: クローズ プロンプトを表示しない場合は、NowChatConfiguration() 呼び出しの closePrompt argument を省略します。 |
| disabledFeatures | [NowChatConfiguration。機能]? | 現在のチャットセッション内で無効にするチャット機能のリスト。 有効な値: startNewConversation:チャットウィンドウに表示される [新しい会話を開始 ] ボタンを非表示/無効にします。 利用可能なチャット機能は、 NowChatOptions.Feature 列挙型クラスで定義されます。 例: 機能を無効にしない場合は、NowChatConfiguration() 呼び出しの disabledFeatures 引数を省略します。 |
| conversationOptions | [NowChatConfiguration。ConversationOption]? | NowChat に適用する会話オプションのリスト。 有効な値:
利用可能な会話オプションは、 NowChatConfiguration.ConversationOption 列挙型クラスで定義されます。 例: 機能を無効にしない場合は、NowChatConfiguration() 呼び出しの conversationOptions 引数を省略します。 |
| UI 構成 | UIConfiguration? | NowChat で UI コンポーネントを構成するために使用する UIConfiguration 値。 有効な値:
例: 提供されたシステム画像の代わりにカスタム画像を使用する場合は、最適な解像度を得るために、画像を幅が 22 〜 44 ピクセル、高さが 30 ピクセルにする必要があります。 AttachmentUploadButtonまたはCloseButtonTypeに既定値を使用するには、関連するボタンを UIConfiguration 引数から省略します。 両方のボタンにデフォルトを使用するには、NowChatConfiguration() 呼び出しの UIConfiguration パラメーターを省略します。 |
| タイプ | 説明 |
|---|---|
| NowChatConfiguration | NowChatConfiguration() メソッドを呼び出すときに渡すことができる NowChatConfiguration オブジェクトを返します。 |
次のコード例は、このメソッドを呼び出してチャット UI を構成する方法を示しています。
func makeChatScreen() -> UIViewController? {
let closePrompt = NowChatConfiguration.ClosePrompt(
header: nil,
message: "Are you sure you want to leave?",
acceptButtonTitle: "Yes",
declineButtonTitle: "No"
)
let disabledFeatures: [NowChatConfiguration.Feature]? = [.startNewConversation]
let conversationOptions: [NowChatConfiguration.ConversationOption]? = [.endConversationOnExit, .forceNewConversation]
let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false)
// Configure close button as Text
let closeButtonText: NowChatConfiguration.CloseButtonType = .text("Exit")
let uiConfigurationWithText = NowChatConfiguration.UIConfiguration(closeButton: closeButtonText, attachmentUploadButton: attachmentUploadButton)
// Configure close button as image
let buttonImage = UIImage(systemName: "arrow.left.circle") ?? nil
var closeButtonImage: NowChatConfiguration.CloseButtonType?
if let buttonImage {
closeButtonImage = .image(buttonImage)
}
let uiConfigurationWithImage = NowChatConfiguration.UIConfiguration(closeButton: closeButtonImage, attachmentUploadButton: attachmentUploadButton)
let chatConfiguration = NowChatConfiguration(closePrompt: closePrompt,
disabledFeatures: disabledFeatures,
conversationOptions: conversationOptions,
uiConfiguration: uiConfigurationWithImage)
let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration)
switch result {
case .success(let chatViewController):
return chatViewController
case .failure(let error):
debugPrint("Chat screen creation failed with error: \(error)")
return nil
}
}
NowChatConfiguration:AttachmentUploadButton (isVisible:ブール値 = true)
ライブエージェントとの会話中にテキスト入力の横に表示される [添付ファイルのアップロード] ボタンに適用する UI 構成を定義します。
AttachmentUploadButton は NowChatConfiguration クラスの構造体です。
| 名前 | タイプ | 説明 |
|---|---|---|
| isVisible | ブール | [添付ファイルのアップロード] ボタンのヴィジビリティを示すフラグ。 有効な値:
デフォルト:true |
| タイプ | 説明 |
|---|---|
| なし |
次のコード例は、AttachmentUploadButton を非表示にする方法を示しています。
func makeChatScreen() -> UIViewController? {
let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false)
let uiConfigurationWithAttachmentButton = NowChatConfiguration.UIConfiguration(attachmentUploadButton: attachmentUploadButton)
let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithAttachmentButton)
let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration)
switch result {
case .success(let chatViewController):
return chatViewController
case .failure(let error):
debugPrint("Chat screen creation failed with error: \(error)")
return nil
}
}
NowChatConfiguration:ClosePrompt(ヘッダー:文字列?、メッセージ:文字列、acceptButtonTitle:文字列、declineButtonTitle:文字列)
渡されたパラメーターに基づいて ClosePrompt オブジェクトを作成して返します。次に、このオブジェクトを NowChatConfiguration() コンストラクターに渡して、チャットセッション内のプロンプトを閉じるオプションを設定します。
| 名前 | タイプ | 説明 |
|---|---|---|
| header | 文字列 | プロンプトのヘッダーに表示するテキスト。 プロンプトヘッダーを表示しない場合は、「nil」を渡します。 |
| メッセージ | 文字列 | プロンプトのメインテキストとして表示するテキスト。 |
| acceptButtonTitle | 文字列 | チャットウィンドウを閉じるためのプロンプトのプライマリボタンに表示するテキスト。 |
| declineButton タイトル | 文字列 | プロンプトを却下するプロンプトのセカンダリボタンに表示するテキスト。 |
次のコード例は、この関数を呼び出す方法を示しています。
func makeChatScreen() -> UIViewController? {
guard let chatService = chatService else { return nil }
let closePrompt = NowChatOptions.ClosePrompt(
header: "Close Window",
message: "Are you sure you want to close the chat window?",
acceptButtonTitle: "Yes",
declineButtonTitle: "No")
let disabledFeatures = [.startNewConversation]
let chatOptions = NowChatOptions(closePrompt: closePrompt,
disabledFeatures: disabledFeatures,
forceNewConversation: true)
let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatOptions: chatOptions)
switch result {
case .success(let chatViewController):
return chatViewController
case .failure(let error):
return nil
}
}
NowChatConfiguration:UIConfiguration(closeButton: CloseButtonType? = nil, attachmentUploadButton: AttachmentUploadButton? = nil)
渡されたパラメーターに基づいて UIConfiguration オブジェクトを作成して返します。次に、このオブジェクトを NowChatConfiguration() コンストラクターに渡して、NowChat で UI コンポーネントを構成します。
UIConfiguration() は NowChatConfiguration クラスの構造体です。
| 名前 | タイプ | 説明 |
|---|---|---|
| 閉じるボタン | CloseButtonType? | NowChat ツールバーに表示され、「戻る」ナビゲーションに使用される CloseButtonType の構成。有効な値:
使用可能な 例: |
| attachmentUploadButton | AttachmentUploadButton? | ライブエージェントとの会話中にテキスト入力の横に表示される AttachmentUploadButton の構成。NowChatConfiguration:AttachmentUploadButton (isVisible:ブール値 = true) メソッドを呼び出して、このパラメーターの値を定義します。 例: |
| タイプ | 説明 |
|---|---|
| オブジェクト | UI 構成オブジェクト |
次のコード例は、 UIConfiguration() サブクラスを呼び出してチャット UI 構成を設定する方法を示しています。
func makeChatScreen() -> UIViewController? {
let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false)
// Configure close button as image
let buttonImage = UIImage(systemName: "arrow.left.circle") ?? nil
var closeButtonImage: NowChatConfiguration.CloseButtonType?
if let buttonImage {
closeButtonImage = .image(buttonImage)
}
let uiConfigurationWithImage = NowChatConfiguration.UIConfiguration(closeButton: closeButtonImage, attachmentUploadButton: attachmentUploadButton)
let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithImage)
let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration)
switch result {
case .success(let chatViewController):
return chatViewController
case .failure(let error):
debugPrint("Chat screen creation failed with error: \(error)")
return nil
}
}