最佳答案
//从 didFinishLaunchingWithOptions 函数调用以下函数。并使用“click_action”键从您的服务器发送响应。
{
"to": "Your FCM ID",
"notification": {
"body": "Hello World",
"title": "This is test message.",
"click_action":"snoozeIn.category"
}
}
//MARK:- Set Action Buttons
func setActionCategories(){
let snoozeAction = UNNotificationAction(
identifier: "snooze.action",
title: "Snooze",
options: [.foreground])
let snoozeCategory = UNNotificationCategory(
identifier: "snoozeIn.category",
actions: [snoozeAction],
intentIdentifiers: [],
options: [])
UNUserNotificationCenter.current().setNotificationCategories(
[snoozeCategory])
}
关于ios - 如何在 swift iOS 的推送通知上添加按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48475186/