简体   繁体   中英

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

在此处输入图片说明

//Call following function from didFinishLaunchingWithOptions function. And send the response from Your server with 'click_action' key.

{
   "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])

        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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