[英]How to add button on Push Notification in swift iOS?
//Call following function from didFinishLaunchingWithOptions function. //从didFinishLaunchingWithOptions函数中调用以下函数。 And send the response from Your server with 'click_action' key.
并使用“ 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])
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.