【发布时间】:2019-09-16 05:13:05
【问题描述】:
我正在尝试在 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 })
但不幸的是,该动作仍未出现。有没有办法做到这一点? 这就是我想要达到的目标。
我的 firebase FCM 设置和所有通知工作正常。我只是无法为这些通知添加操作。
【问题讨论】:
标签: ios swift firebase-cloud-messaging