用户点击通知后用户通知中心的响应未完成

时间:2019-03-29 14:52:42

标签: ios swift unusernotificationcenter

这是userInfo,当我将远程通知传递到设备时,我从服务器收到了

[AnyHashable("extras"): {"message":{"created_time":"2019-03-29T15:43:41.174+01:00","app_label":true,"deletable":true,"message_type":"PUSH_ONLY","id":408,"title":{"en":"Title for push message"},"body":{"en":"

Body for push message"},"reservation_number":"12345"}}, AnyHashable("gcm.message_id"): 0:1553870624484816%003a4e4c003a4e4c, AnyHashable("google.c.a.e"): 1, AnyHashable("event_type"): NEW_MESSAGE, AnyHashable("aps"): { alert = { "loc-key" = "Message.New.Body"; "title-loc-key" = "Message.New.Title"; }; "content-available" = 1; sound = default; }]

这是我捕获该信息的地方

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { }

对我来说重要的信息在这里

  

“ message_type”:“ PUSH_ONLY”

此类通知可能会与用户的点击互动。然后调用以下方法:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { }

但是如果我打印response,则会收到:

<UNNotificationResponse: 0x283d2bc00; actionIdentifier: com.apple.UNNotificationDefaultActionIdentifier, notification: <UNNotification: 0x283d29800; date: 2019-03-29 14:13:20 +0000, request: <UNNotificationRequest: 0x2832def70; identifier: 01CFAF34-57A0-4BE4-8D88-EDD90D93AC2F, content: <UNNotificationContent: 0x2808cc600; title: You have received a new message, subtitle: (null), body: Open the app to see its content, summaryArgument: (null), summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: , attachments: (), badge: (null), sound: <UNNotificationSound: 0x2819a1020>,, trigger: <UNPushNotificationTrigger: 0x283fefeb0; contentAvailable: YES, mutableContent: NO>>>>

您会看到没有 message_type信息。基于该键,当用户点击通知时,我需要在应用程序内执行不同的操作。我现在该怎么办?

0 个答案:

没有答案