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

UNUserNotificationCenter is used for iOS 10 and above devices.

If your push don't reflect on iOS:

In scenarios where push notifications do not reflect when clicked on iOS devices, this method may be utilized. It should be placed at the top of didFinishLaunchingWithOptions.

//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 top line under didFinish.

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