Links

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.
Swift
Objective-C
//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.
//in didFinishLaunchingWithOptions
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
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.
Swift
Objective-C
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
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
//NetmeraPushObject *object = [[NetmeraPushObject alloc] initWithDictionary: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.
Swift
Objective-C
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
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
//[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.
Swift
Objective-C
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
completionHandler(UNNotificationPresentationOptionAlert);
}

Take Push Token Method

Swift
Objective-C
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{}