gpt4 book ai didi

ios - 在 Swift 4 中将 UNNotificationAction 添加到 firebase FCM 推送通知

转载 作者:行者123 更新时间:2023-11-28 05:38:06 26 4
gpt4 key购买 nike

我正在尝试在 FCM 推送通知时添加一些自定义操作。我在注册通知后尝试添加这些。

UNUserNotificationCenter.current().delegate = self
let acceptAction = UNNotificationAction(identifier: "ACCEPT_ACTION",
title: "Accept",
options: UNNotificationActionOptions(rawValue: 0))
let declineAction = UNNotificationAction(identifier: "DECLINE_ACTION",
title: "Decline",
options: UNNotificationActionOptions(rawValue: 0))
let center = UNUserNotificationCenter.current()
if #available(iOS 11.0, *) {
let meetingInviteCategory = UNNotificationCategory(identifier: "MEETING_INVITATION",
actions: [acceptAction, declineAction],
intentIdentifiers: [],
hiddenPreviewsBodyPlaceholder: "",
options: .customDismissAction)
center.setNotificationCategories([meetingInviteCategory])
}
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]


center.requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })

但不幸的是,这个 Action 还没有出现。无论如何要实现这一目标?这就是我想要实现的目标。

example

我的 firebase FCM 设置和所有通知工作正常。我只是无法向这些通知添加操作。

最佳答案

我明白了。我只需要在 fcm/send 的正文中添加 click_action 字段。并将该 click_action 键设置为类别标识符。

关于ios - 在 Swift 4 中将 UNNotificationAction 添加到 firebase FCM 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57950715/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com