簡體   English   中英

如何在Swift iOS中的推送通知上添加按鈕?

[英]How to add button on Push Notification in swift iOS?

我正在使用Firebase推送通知,我正確地收到了通知,但是當用戶滑動該通知並點擊“查看”時,我想在該通知下方添加按鈕,如下圖所示

在此處輸入圖片說明

//從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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM