Я реализовал интерактивное уведомление pu sh в своем приложении, как показано ниже,
в didFinishLaunchingWithOptions
set
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (_, _) in }
let accept = UNNotificationAction(identifier: "accept", title: "Accept", options: [])
let deny = UNNotificationAction(identifier: "deny", title: "Deny", options: [])
let category = UNNotificationCategory(identifier: "newFriendRequest", actions: [accept, deny], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
и
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
NSLog("FR_ didReceive userNotification")
completionHandler()
}
Когда я нажимаю кнопку любого действия в уведомлении pu sh, когда приложение неактивно, я получаю следующую ошибку в Console App .
FR_ didReceive userNotification
Application background launch action for notification response action deny recieved action response <BSActionResponse: 0x28043c700; error: <NSError: 0x2808847b0; domain: BSActionErrorDomain; code: 4> {
description = "The operation couldn’t be completed. (BSActionErrorDomain error 4.)";
}>
Примечание: Я получаю эту ошибку, если я обработал или не обработал ответ didReceive
.