【问题标题】:Read Push Notification payload details in getDeliveredNotifications(completionHandler:) method在 getDeliveredNotifications(completionHandler:) 方法中读取推送通知有效负载详细信息
【发布时间】:2017-12-13 10:09:53
【问题描述】:

这是我的推送通知负载。

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

无法在 ios10 的 getDeliveredNotifications 方法内的通知对象中读取上述有效负载键和值。

这是getDeliveredNotifications方法内的通知对象详细信息。

<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>>>

除了通知对象的正文键中存在的通知消息“新通知”之外,没有关于我在推送通知中发送的有效负载的信息,有没有办法读取通知对象中的所有有效负载键。任何帮助将不胜感激。

【问题讨论】:

    标签: swift notifications apple-push-notifications ios10


    【解决方案1】:

    您的有效负载应该在通知内容的 userInfo 字典中:

    let userInfo = notification.request.content.userInfo
    print userInfo["userId"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-28
      • 2017-07-23
      • 2019-08-16
      • 1970-01-01
      • 2021-04-26
      • 1970-01-01
      • 2017-05-31
      • 2018-04-04
      相关资源
      最近更新 更多