Push Payload Receivers

If you want to retrieve the notification payload sent to the device, you can use the following methods in the AppDelegate class. Netmera swizzles iOS methods.

UNUserNotificationCenter

Netmera SDK automatically collects Click Push Events. However, if you have issues with collection of this event make sure the following UNUserNotificationCenter method is placed at the top line in didFinishLaunchingWithOptions. This configuration ensures click events on notifications are processed correctly.

Implement UNUserNotificationCenter in didFinishLaunchingWithOptions

Insert the code below at the beginning of didFinishLaunchingWithOptions in your app’s AppDelegate file:

//in didFinishLaunchingWithOptions

if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
  } else {
    // Fallback on earlier versions
  }

This method should be placed at the beginning (top line) of the didFinishLaunchingWithOptions method in your app’s AppDelegate file.

Push Payload for Push Click

This method is used to take the push payload when the push notification is clicked.

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
//NetmeraPushObject(dictionary: response.notification.request.content.userInfo)
//object.alert.body                  //Push Text
//object.alert.title                 //Push Title
//object.action.deeplinkURL          //Push Deeplink
//object.customDictionary            //Custom JSON
}

Push Payload for Push Received

Take push payload for push received. This method will return latest push object received by device.

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
{
//Netmera.recentPushObject()?.alert.body                  //Push Text
//Netmera.recentPushObject()?.alert.title                 //Push Title
//Netmera.recentPushObject()?.action.deeplinkURL          //Push Deeplink
//Netmera.recentPushObject()?.customDictionary            //Custom JSON
}

Push Payload for Push Received on Application Foreground

Take push payload for push Received on application foreground.

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler(.alert)
        }

Take Push Token Method

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{}

Last updated