【问题标题】:Swift UNNotificationRequest identifier of action button tapped local notification动作按钮的 Swift UNNotificationRequest 标识符点击了本地通知
【发布时间】:2021-09-06 07:10:27
【问题描述】:

是否可以获得点击的本地通知按钮的 UNNotificationRequest 标识符或有关通知的任何其他信息?也许通过委托?

谢谢

【问题讨论】:

标签: swift notifications identifier unnotificationrequest


【解决方案1】:

通知的标识符是这样获取的:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        
        let identifier = response.notification.request.identifier
        
        switch response.actionIdentifier {
        
        case "snoozeAction":
            
            print ("Snooze Tapped - identifier :", identifier)
            
            nc.post(name: Notification.Name("didTapSnooze"), object: nil)
            
            
        default:
            break
        }
        
        completionHandler()
        
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    相关资源
    最近更新 更多