NotificationHelper

public protocol NotificationHelper

Undocumented

  • pushHandler that will handle all push notification navigation except Rich Push Notification

    Declaration

    Swift

    var pushHandler: PushHandler { get }
  • RichPushHandler that will handle all Rich Push Notification Quick Actions

    Declaration

    Swift

    var richPushHandler: RichPushHandler { get }
  • Device ID that will be used when registering the device to the server along with the device token

    Declaration

    Swift

    var deviceId: String { get }
  • Register to receive remote notifications via Apple Push Notification service.

    Declaration

    Swift

    func registerForRemoteNotifications()
  • Requests authorization to interact with the user when local and remote notifications are delivered to the user’s device.

    Declaration

    Swift

    func requestAuthorization(options: UNAuthorizationOptions,
                              completion: @escaping (_ granted: Bool, _ error: Error?) -> Void)

    Parameters

    options

    The authorization options your app is requesting.

    completion

    The closure to execute asynchronously with the results. It has no return value and has a boolean and an error object as a parameters.

    granted

    A boolean indicating whether authorization was granted.

    error

    The error object containing error information or nil if no error occurred.

  • Send the device token to a server API call.

    This method is usually called inside the application’s didRegisterForRemoteNotificationsWithDeviceToken method to get the device token.

    Important

    Never send the same device token to the server. It can be done by saving the device token somewhere (preferably the Keychain), then checking if the fetched device token is the same with the one that was saved.

    Declaration

    Swift

    func sendDeviceTokenToServerIfNeeded(_ deviceToken: Data)

    Parameters

    deviceToken

    The token of the device as Data.

  • Calls MessagesAPI.trackMessage(id: id, action: .opened)

    Declaration

    Swift

    func trackMessage(id: Int)

    Parameters

    id

    Message ID

  • Sets the Application’s badge count with the given number if allowed

    Declaration

    Swift

    func setApplicationBadgeCount(_ count: Int)

    Parameters

    count

    Number to be displayed on Application’s Icon

  • Handles Notification Responses

    Declaration

    Swift

    func handleNotificationResponse(_ response: UNNotificationResponse, completionHandler: @escaping () -> Void)

    Parameters

    response

    The UNNotificationResponse based on the user’s interaction

    completionHandler

    Completion block that should always be called regardless if the modification succeeded or failed