ZendeskSDK Documentation

Class Zendesk

@objc public final class Zendesk: NSObject  

The entry point to execute SDK actions. To obtain an instance use Zendesk.initialize(channelKey:completionHandler:).

Zendesk Zendesk NSObject NSObject Zendesk->NSObject Loggable Loggable Zendesk->Loggable

Conforms To

Loggable
NSObject

Properties

messaging

@objc public var messaging: Messaging?  

Optional property allows integrators to interact with the Messaging capability and its feature set.

instance

@objc public static var instance: Zendesk?  

Optional property allows integrators to interact with the initialized Zendesk instance.

initialization​Phase

public private(set) static var initializationPhase = InitializationPhase.notProcessing

log​Namespace

public static var logNamespace: String  

log​Category

public static var logCategory: String  

Methods

initialize(with​Channel​Key:​messaging​Factory:​completion​Handler:​)

public class func initialize(withChannelKey channelKey: String,
                                 messagingFactory: MessagingFactory? = nil,
                                 completionHandler: @escaping (Result<Zendesk, Error>) -> Void)  

Initializes Zendesk for the given channelKey. A MessagingFactory can be optionally passed here to add the Messaging capability. This method is an asynchronous call that retrieves settings from the network that calls the completionHandler with the result.

Parameters

channel​Key String

The key of your Messaging iOS channel

messaging​Factory Messaging​Factory?

Optional parameter to include the Messaging capability, pass an initialized DefaultMessagingFactory here.

completion​Handler @escaping (Result<Zendesk, Error>) -> Void

A block that takes a Result enum type. In the case of a success, a Zendesk instance will be returned, in the case of a failure an Error type.

send​Page​View​Event(_:​completion​Handler:​)

public func sendPageViewEvent(_ pageView: PageView, completionHandler: @escaping (Result<Void, Error>) -> Void)  

Send a page view event, that captures a specific user interaction, to the PageView endpoint.

Parameters

page​View Page​View

The PageView object that contains information related to a user's interactions e.g. the title of the page that was visited.

completion​Handler @escaping (Result<Void, Error>) -> Void

A block that takes a Result enum type. In the case of a success, nothing is returned. In the case of a failure an Erroris returned.

invalidate()

@objc public static func invalidate()  

Invalidates the current instance of Zendesk. After calling this method you will have to call Zendesk.initialize() again if you would like to use Zendesk.

add​Event​Observer(_:​_:​)

public func addEventObserver(_ observer: AnyObject,
                                 _ completionHandler: @escaping (ZendeskEvent) -> Void)  

Add an event observer to observe events emitted from Zendesk.

Parameters

observer Any​Object

The object in which events will be received.

completion​Handler @escaping (Zendesk​Event) -> Void

Block that receives a ZendeskEvent.

remove​Event​Observer(_:​)

@objc public func removeEventObserver(_ observer: AnyObject)  

Remove event observer to stop observing events emitted by from Zendesk.

login​User(with:​completion​Handler:​)

func loginUser(with jwt: String, completionHandler: ((Result<ZendeskUser, Error>) -> Void)? = nil)  

Authenticate a user.

Parameters

jwt String

The jwt belonging to the user.

completion​Handler ((Result<Zendesk​User, Error>) -> Void)?

A block that takes a Result enum type. In the case of a success, a ZendeskUser will be returned, in the case of a failure an Error.

logout​User(completion​Handler:​)

func logoutUser(completionHandler: ((Result<Void, Error>) -> Void)? = nil)  

Unauthenticate a user.

Parameters

completion​Handler ((Result<Void, Error>) -> Void)?

A block that takes a Result enum type. In the case of a success, nothing is returned, in the case of a failure an Error.

login​User(with:​completion​Handler:​)

@available(swift, obsoleted: 1.0)
    @objc func loginUser(with jwt: String, completionHandler: ((ZendeskUser?, Error?) -> Void)? = nil)  

Authenticate a user.

Parameters

jwt String

The jwt belonging to the user.

completion​Handler ((Zendesk​User?, Error?) -> Void)?

A block that takes an optional ZendeskUser which will be non-nil in the case of a success, and an optional Error which will be non-nil in the case of a failure.

logout​User(completion​Handler:​)

@available(swift, obsoleted: 1.0)
    @objc func logoutUser(completionHandler: ((Error?) -> Void)? = nil)  

Unauthenticate a user.

Parameters

completion​Handler ((Error?) -> Void)?

A block that takes an optional Error which will be non-nil in the case of a failure.

initialize(channel​Key:​messaging​Factory:​completion​Handler:​)

@available(swift, obsoleted: 1.0)
    @objc static func initialize(channelKey: String,
                                 messagingFactory: MessagingFactory?,
                                 completionHandler: ((Zendesk?, Error?) -> Void)?)  

Initializes Zendesk for the given channelKey. A MessagingFactory can be optionally passed here to add the Messaging capability. This method is an asynchronous call that retrieves settings from the network that calls the completionHandler with the result.

Parameters

channel​Key String

The key of your Messaging iOS channel

messaging​Factory Messaging​Factory?

Optional parameter to include the Messaging capability, pass an initialized DefaultMessagingFactory here.

completion​Handler ((Zendesk?, Error?) -> Void)?

A block that takes an optional Zendesk instance which will be non-nil in the case of a success and an optional Error which will be non-nil in the case of a failure.

add​Event​Observer(_:​_:​)

@available(swift, obsoleted: 1.0)
    @objc func addEventObserver(_ observer: AnyObject,
                                _ completionHandler: ((ZDKZendeskEvent, AnyObject?) -> Void)?)  

Add an event observer to observe events emitted from Zendesk.

Parameters

observer Any​Object

The object in which events will be received.

completion​Handler ((ZDKZendesk​Event, Any​Object?) -> Void)?

A block that receives a ZDKZendeskEvent.

send​Page​View​Event(_:​completion​Handler:​)

@available(swift, obsoleted: 1.0)
    @objc func sendPageViewEvent(_ pageView: PageView,
                                 completionHandler: ((Error?) -> Void)?)  

Send a page view event, that captures a specific user interaction, to the PageView endpoint.

Parameters

page​View Page​View

The PageView object that contains information related to a user's interactions e.g. the title of the page that was visited.

completion​Handler ((Error?) -> Void)?

A block that takes an optional Error which will be non-nil in the case of a failure.