You can listen for different events that occur in the SDK API and UI.
Before you start
Before you start, the following information is useful to know:
- You can hook onto lifecycle events called during the normal operation of UI and API calls.
- You can then use this information to perform other actions in your app. For example, if you know that a support request has been created, you may want to suppress marketing activity.
Listening for events
The Support SDK broadcasts state changes using
NSNotificationCenter. To subscribe to an event, add an observer to
NotificationCenter.default.addObserver(self, selector: #selector(submitRequestCompleted), name: NSNotification.Name(rawValue: ZDKAPI_RequestSubmissionSuccess), object: nil)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(submitRequestCompleted:) name:ZDKAPI_RequestSubmissionSuccess object:nil];
For more information, see NSNotificationCenter in the Apple developer docs.
A full list of events is available in the ZendeskSDKConstants.h file in the SDK. The file is located in the ZendeskProviderSDK.framework/Headers folder after installing the SDK. The file is also available in the following GitHub repo (the version number may vary):
Event names have the following format:
Example from ZendeskSDKConstants.h:
/** * Notification that a request has been successfully submitted. */ extern NSString * const ZDKAPI_RequestSubmissionSuccess;
The events in the following sections are only a subset of all available events.
Request submission events
The SDK lets you track the progress of support requests submitted by users.
|ZDKAPI_RequestSubmissionStarting||A request is about to be submitted|
|ZDKAPI_RequestSubmissionSuccess||A request has been successfully submitted|
|ZDKAPI_RequestSubmissionError||There was an error during request submission|
You can attach a listener to
ViewRequest and be notified of the following events.
|ZDKAPI_CommentListStarting||The comment list is about to be retrieved|
|ZDKAPI_CommentListSuccess||The comment list has been retrieved|
|ZDKAPI_CommentListError||There was an error while retrieving the comment list|
|ZDKAPI_CommentSubmissionStarting||A comment is about to be submitted|
|ZDKAPI_CommentSubmissionSuccess||A comment has been successfully submitted|
|ZDKAPI_CommentSubmissionError||There was an error during comment submission|
Request list events
You can attach observers to
RequestList and be notified of the following events.
|ZDKAPI_RequestsStarting||The request list is about to be retrieved|
|ZDKAPI_RequestsSuccess||The request list was successfully retrieved|
|ZDKAPI_RequestsError||There was an error while retrieving the request list|