Chat
@objc(ZDKChat)
public final class Chat : NSObject, Loggable
Chat is a singleton class of the ChatProviderSDK.
It needs to be intialized with an accountKey before using any of the Chat APIs.
The accountKey can be retrieved from the Zendesk Chat dashboard.
Chat.initialize(accountKey: accountKey)
-
Called when
Chatreceives push notification with messageDeclaration
Swift
@objc public static let NotificationMessageReceived: NSNotification.Name -
This notification is called when
Chatsession did endDeclaration
Swift
@objc public static let NotificationChatEnded: NSNotification.Name -
This notification is called when the user authentication failed.
Declaration
Swift
@objc public static let NotificationAuthenticationFailed: NSNotification.Name -
Account key
Declaration
Swift
@objc public let accountKey: String -
App id
Declaration
Swift
@objc public let appId: String? -
Grouping of Zendesk Chat’s providers
Declaration
Swift
@objc public internal(set) var providers: Providers { get } -
Static instance of the Chat provider
Declaration
Swift
@objc public static var instance: Chat? { get } -
Set configuration to start
Chatwith pre-configureddepartment,visitorInfoandtags.Note
Department can be changed only before theChathas started. Changing the department during the ongoingChatis not allowed.Declaration
Swift
@objc public var configuration: ChatAPIConfiguration { get set }
-
Set configuration to start
Chatwith pre-configureddepartment,visitorInfoandtags.Note
Department can be changed only before theChathas started. Changing the department during the ongoingChatis not allowed.Declaration
Swift
@objc public static var configuration: ChatAPIConfiguration { get } -
Whether a user is authenticated.
Declaration
Swift
@objc public static var hasIdentity: Bool { get } -
Account Provider
Declaration
Swift
@objc public static var accountProvider: AccountProvider? { get } -
Connection Provider
Declaration
Swift
@objc public static var connectionProvider: ConnectionProvider? { get } -
Profile Provider
Declaration
Swift
@objc public static var profileProvider: ProfileProvider? { get } -
Push Notifications Provider
Declaration
Swift
@objc public static var pushNotificationsProvider: PushNotificationsProvider? { get } -
Chat Provider
Declaration
Swift
@objc public static var chatProvider: ChatProvider? { get } -
Settings Provider
Declaration
Swift
@objc public static var settingsProvider: SettingsProvider? { get }
-
Whether a user is authenticated.
Declaration
Swift
@objc public var hasIdentity: Bool { get } -
Account Provider
Declaration
Swift
@objc public var accountProvider: AccountProvider { get } -
Connection Provider
Declaration
Swift
@objc public var connectionProvider: ConnectionProvider { get } -
Push Notifications Provider
Declaration
Swift
@objc public var pushNotificationsProvider: PushNotificationsProvider { get } -
Profile Provider
Declaration
Swift
@objc public var profileProvider: ProfileProvider { get } -
Chat Provider
Declaration
Swift
@objc public var chatProvider: ChatProvider { get } -
Settings Provider
Declaration
Swift
@objc public var settingsProvider: SettingsProvider { get } -
Initializes chat with Chat’s accountkey
Declaration
Swift
@objc public class func initialize(accountKey: String, appId: String? = nil, queue: DispatchQueue = .main)Parameters
accountKeyThe accountKey from your chat instance
appIdThe app id
queuethe queue to dispatch chat operations on. Default is
.main
-
Clears the cache Call this method when leaving the conversation screen
Declaration
Swift
@objc public func clearCache() -
Set the authenticated user’s identity
Declaration
Swift
@objc public func setIdentity(authenticator: JWTAuthenticator)Parameters
authenticatorInstance of the class that conforms to
JWTAuthenticatorprotocol -
Resets the visitor data to a clean state allowing a new visitor to chat
Any ongoing chat will be ended, and locally stored information about the visitor will be cleared, including the registered push token. Make sure to re-register for push notifications as needed.
Declaration
Swift
@objc public func resetIdentity(_ completion: (() -> Void)? = nil) -
Resets the visitor data to a clean state allowing a new visitor to chat
Declaration
Swift
@available(*, deprecated, message: "Please use `resetIdentity(_ completion: ((﹚ -> Void﹚?﹚` instead") @objc public func resetIdentity()
-
Sends push token to server
Declaration
Swift
@objc public class func registerPushToken(_ pushTokenData: Data)Parameters
pushTokenDatadevice token received in
didRegisterForRemoteNotificationsWithDeviceTokenafter registration -
Sends push token to server
Declaration
Swift
@objc public class func registerPushTokenString(_ pushTokenString: String)Parameters
pushTokenStringdevice token received in
didRegisterForRemoteNotificationsWithDeviceTokenafter registration -
Pass the received remote notification to
didReceiveRemoteNotification. If the push notification belongs to Zendesk Chat, the push notification will be processed accordinglyThere are currently two types of supported Push Notifications:
New chat message- This event happens, when there’s new message typed by an agent.
In order to respond to this event, you can observe the notification with name
PushNotificationsProvider.ChatMessageReceivedNotificationinNotificationCenter.
- This event happens, when there’s new message typed by an agent.
In order to respond to this event, you can observe the notification with name
Chat has ended- When this event is received, the Chat will be ended and the chat session will be disconnected
In order to respond to this event, you can observe the notification with name
Chat.NotificationChatEndedinNotificationCenter.
- When this event is received, the Chat will be ended and the chat session will be disconnected
In order to respond to this event, you can observe the notification with name
Declaration
Swift
@objc public class func didReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], in application: UIApplication)Parameters
userInfoA dictionary that contains information related to the remote notification
applicationThe centralized point of control and coordination for apps running in iOS.
Install in Dash
Chat Class Reference