简体   繁体   English

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

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

I am using firebase push notification, I received notification correctly but when user slide that notification and tap on 'view' then I want to add button below that notification like the following image 我正在使用Firebase推送通知,我正确地收到了通知,但是当用户滑动该通知并点击“查看”时,我想在该通知下方添加按钮,如下图所示

在此处输入图片说明

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM