I'm using Xcode 9.4.1 (9F2000)
and Swift
.
I have this code in AppDelegate
:
func showPushButtons(){
let replyAction = UNNotificationAction(
identifier: "reply.action",
title: "Reply to this message",
options: [])
let pushNotificationButtons = UNNotificationCategory(
identifier: "allreply.action",
actions: [replyAction],
intentIdentifiers: [],
options: [])
UNUserNotificationCenter.current().setNotificationCategories([pushNotificationButtons])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let action = response.actionIdentifier
let request = response.notification.request
let content = response.notification.request.content.userInfo
if action == "reply.action"{
print("Reply button clicked")
completionHandler()
}
}
This makes the following:
When receiving a push notification, an action button will be visible called Reply to this message
.
Currently, when clicking on the button, console prints Reply button clicked
.
What I want to do:
If I click on the button a textfield and the keyboard should appear (as known from messaging apps). After writing some text and submitting/sending I want to receive this message in AppDelegate
to handle it.
Do you have any idea how to do this? Any hint?