[英]How to add button on Push Notification in swift iOS?
//從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])
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.