Using Push Service


Push Service is responsible for registering the device for the push notifications about the Operations that are tied to the current PowerAuth activation.

Note: Before using Push Service, you need to have a PowerAuthSDK object available and initialized with a valid activation. Without a valid PowerAuth activation, service will return an error

Push Service communicates with Mobile Push Registration API.

Creating an Instance

To create an instance of the push service, use the following snippet:

import WultraMobileTokenSDK

let opsConfig = WMTConfig(
    baseUrl: URL(string: "")!,
    sslValidation: .default
let pushService = powerAuth.createWMTPush(config: config)

sslValidation property is used when validating HTTPS requests. Following strategies can be used.

  • WMTSSLValidationStrategy.default
  • WMTSSLValidationStrategy.noValidation
  • WMTSSLValidationStrategy.sslPinning

Push Service API Reference

All available methods of the WMTPush API are:

  • pushNotificationsRegisteredOnServer - If there was already made an successful request.
  • config - Config object, that was used for initialization.
  • acceptLanguage - Language settings, that will be sent along with each request.
  • registerDeviceTokenForPushNotifications(token: Data, completionHandler: @escaping (_ success: Bool, _ error: WMTError?) -> Void) - Registers push token on the backend.
    • token - token data retrieved from APNS.
    • completionHandler - Called when request finishes. Always called on the main thread.

Registering to WMT Push Notifications

To register your app to push notifications regarding the operations, you can simply call the registerDeviceTokenForPushNotifications method:

// UIApplicationDelegate method
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    pushService.registerDeviceTokenForPushNotifications(token: deviceToken) { success, error in
        guard success else {
            // push registration failed

The above method will get called only if you registered the app to receive push notifications. For more information, visit the official documentation.

Receiving WMT Push Notifications

To process the raw notification obtained from Apple Push Notification service (APNs), you can use WMTPushParser helper class that will parse the notification into a WMTPushMessage result.

The WMTPushMessage can be following values

  • operationCreated - a new operation was triggered with the following parameters
    • id of the operation
    • name of the operation
    • content (optional) of the message presented to the user.
    • originalData - data on which was the push message constructed
  • operationFinished - an operation was finished, successfully or non-successfully with following parameters
    • id of the operation
    • name of the operation
    • result of the operation (for example that the operation was canceled by the user).
    • originalData - data on which was the push message constructed

Example push notification processing:

// MARK: - UNUserNotificationCenterDelegate
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    if let wmtnf = WMTPushParser.parseNotification(notification) {
        // process the mtoken notification and react to it in the UI
    }  else {
       // process all the other notification types using your own logic

Error handling

Every error produced by the Push Service is of a WMTError type. For more information see detailed error handling documentation.

Last updated on Nov 04, 2021 (10:59) Edit on Github Send Feedback


Mobile Token

Mobile Token SDK for iOS