PushHandler

interface PushHandler

Defines contract for managing push device enrollment and handling notification messages from a specific platform.

Functions

Link copied to clipboard
abstract fun canHandle(message: String): Boolean

Check if this handler can process the given message in string format. This method should inspect the message string to determine if it can be handled by this handler. It should return true if the handler can process the message, and false otherwise.

abstract fun canHandle(messageData: Map<String, Any>): Boolean

Check if this handler can process the given message. This method should inspect the message data to determine if it can be handled by this handler. It should return true if the handler can process the message, and false otherwise.

Link copied to clipboard
abstract fun parseMessage(message: String): Map<String, Any>

Parse the message received as a string. It should extract relevant information from the string message (typically a JWT or JSON string) and return a map of parsed data that maps to the expected structure for the PushNotification. Any required fields should be included in the map.

abstract fun parseMessage(messageData: Map<String, Any>): Map<String, Any>

Parse the message data received from the push service. It should extract relevant information such as notification type, message content, and any additional parameters. It should return a map of parsed data that maps to the expected structure for the PushNotification. Any required fields should be included in the map. Additional fields can also be included for further processing.

Link copied to clipboard
abstract suspend fun register(credential: PushCredential, params: Map<String, Any>): Boolean

Register a new push credential with the server, if this is required by the platform. The parameters may include additional information or any other relevant data that the server needs to process the registration.

Link copied to clipboard
abstract suspend fun sendApproval(credential: PushCredential, notification: PushNotification, params: Map<String, Any>): Boolean

Send to the server an approval response for a notification that was received. How the approval is sent depends on the platform and the implementation of this handler. The parameters may include additional information or any other relevant data that the server needs to process the approval.

Link copied to clipboard
abstract suspend fun sendDenial(credential: PushCredential, notification: PushNotification, params: Map<String, Any>): Boolean

Send a denial response for a notification. How the denial is sent depends on the platform and the implementation of this handler. The parameters may include additional information or any other relevant data that the server needs to process the denial.

Link copied to clipboard
abstract suspend fun setDeviceToken(credential: PushCredential, deviceToken: String, params: Map<String, Any>): Boolean

Register or update the device token. This is typically called when the device token changes.