Read Push Notification payload details in getDeliveredNotifications(completionHandler:) method
Asked Answered
F

1

5

This is my push notification payload.

{
    "userId":"QA-207-222820",
    "title":"Push new Notification",
    "message":"New Notification",
    "deviceId":"70",
    "deviceName":"R70",
    "notificationType":"1"
}

Not able to read above payload keys and values in notification object inside getDeliveredNotifications method in ios10.

Here is the notification object details inside getDeliveredNotifications method.

<UNNotification: 0x1742389a0; date: 2017-12-13 09:34:59 +0000,

 request: <UNNotificationRequest: 0x1742389c0; identifier: 067437A1-E8F3-4805-B6D9-
A57BE48E9554, 

content: <UNNotificationContent: 0x17410ba30; title: (null), 
subtitle: (null), body: New Notification 
, categoryIdentifier: , launchImageName: , peopleIdentifiers: (
), threadIdentifier: , attachments: (
), badge: (null), 

sound: <UNNotificationSound: 0x1740b75e0>, 
hasDefaultAction: YES, defaultActionTitle: (null), shouldAddToNotificationsList: YES,
shouldAlwaysAlertWhileAppIsForeground: NO, shouldLockDevice: NO, shouldPauseMedia: NO, 
isSnoozeable: NO, fromSnooze: NO, darwinNotificationName: (null), darwinSnoozedNotificationName: (null), 

trigger: <UNPushNotificationTrigger: 0x17400e2a0; contentAvailable: YES, mutableContent: NO>>>

There is no info about the payload i sent in my push notification except my notification message "New Notification" which is present in body key in notification object ,is there any way to read all the payload keys in notification object.Any help would be appreciated.

Finding answered 13/12, 2017 at 10:9 Comment(0)
K
14

Your payload should be in the userInfo dictionary of the notification content:

let userInfo = notification.request.content.userInfo
print userInfo["userId"]
Kabuki answered 13/12, 2017 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.