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 Chat receives push notification with message

    Declaration

    Swift

    @objc
    public static let NotificationMessageReceived: NSNotification.Name
  • This notification is called when Chat session did end

    Declaration

    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 Chat with pre-configured department, visitorInfo and tags.

    NOTE: Department can be changed only before the Chat has started. Changing the department during the ongoing Chat is not allowed.

    Declaration

    Swift

    @objc
    public var configuration: ChatAPIConfiguration { get set }

Static Providers

Providers

Cache

  • 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

    authenticator

    Instance of the class that conforms to JWTAuthenticator protocol

  • 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()

Push Notifications

  • Sends push token to server

    Declaration

    Swift

    @objc
    public class func registerPushToken(_ pushTokenData: Data)

    Parameters

    pushTokenData

    device token received in didRegisterForRemoteNotificationsWithDeviceToken after registration

  • Sends push token to server

    Declaration

    Swift

    @objc
    public class func registerPushTokenString(_ pushTokenString: String)

    Parameters

    pushTokenString

    device token received in didRegisterForRemoteNotificationsWithDeviceToken after registration

  • Pass the received remote notification to didReceiveRemoteNotification. If the push notification belongs to Zendesk Chat, the push notification will be processed accordingly

    There are currently two types of supported Push Notifications:

    • New chat message

    • 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.NotificationChatEnded in NotificationCenter.

    Declaration

    Swift

    @objc
    public class func didReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], in application: UIApplication)

    Parameters

    userInfo

    A dictionary that contains information related to the remote notification

    application

    The centralized point of control and coordination for apps running in iOS.