Handle events

This page shows you how to listen for different events that occur in the API and UI we provide.

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 wish to suppress marketing activity.

Listen for events

The Support SDK broadcasts state changes using NSNotificationCenter. To subscribe to the events listed on this page, add an observer to NSNotificationCenter.

Swift 3

NotificationCenter.default.addObserver(self, selector: #selector(submitRequestCompleted), name: NSNotification.Name(rawValue: ZDKAPI_RequestSubmissionSuccess), object: nil)

Objective-C

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(submitRequestCompleted:)
                                             name:ZDKAPI_RequestSubmissionSuccess
                                           object:nil];

For more information on NSNotificationCenter, see Notification Programming Topics.

Available ticket submission events

We provide a mechanism to let you track the progress of feedback submissions by users. This is done by broadcasting state changes using NSNotificationCenter. The following is a snippet from ZendeskSDKConstants.h:

/**
 * Notification that a request is about to be submitted.
 */
extern NSString * const ZDKAPI_RequestSubmissionStarting;

/**
 * Notification that a request has been successfully submitted.
 */
extern NSString * const ZDKAPI_RequestSubmissionSuccess;

/**
 * Notification that there was an error during request submission.
 */
extern NSString * const ZDKAPI_RequestSubmissionError;

Available request list events

You can attach additional observers to RequestList. This allows you to be notified of additional events as they occur. The following is the interface definition containing the events that are currently available.

/**
 * Notification that the request list is about to be retrieved.
 */
extern NSString * const ZDKAPI_RequestsStarting;

/**
 * Notification that the request list was successfulyl retrieved.
 */
extern NSString * const ZDKAPI_RequestsSuccess;

/**
 * Notification that there was an error while retrieving the request list.
 */
extern NSString * const ZDKAPI_RequestsError;

Available single request events

You can attach an additional listener to ViewRequest. This allows you to be notified of additional events as they occur. The following is the interface definition containing the events that are currently available.

/**
 * Notification that the list is about to be retrieved.
 */
extern NSString * const ZDKAPI_CommentListStarting;

/**
 * Notification that the list has been retrieved.
 */
extern NSString * const ZDKAPI_CommentListSuccess;

/**
 * Notification that there was an error while retrieving the comment list.
 */
extern NSString * const ZDKAPI_CommentListError;

/**
 * Notification that a comment is about to be submitted.
 */
extern NSString * const ZDKAPI_CommentSubmissionStarting;

/**
 * Notification that a comment has been successfully submitted.
 */
extern NSString * const ZDKAPI_CommentSubmissionSuccess;

/**
 * Notification that there was an error during comment submission.
 */
extern NSString * const ZDKAPI_CommentSubmissionError;