Это 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":"<p>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
отсутствует. Основываясь на этом ключе, мне нужно выполнять различные действия в приложении, когда пользователь нажимает на уведомление. Как я могу сделать это сейчас?