jat
jat

Reputation: 347

Swift UNNotificationRequest identifier of action button tapped local notification

Is it possible to get the UNNotificationRequest identifier of a tapped local notification button or any other information about the notification? Maybe via a delegate?

Thankyou

Upvotes: 0

Views: 492

Answers (1)

jat
jat

Reputation: 347

The identifier of the notification is obtained like so:

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()
        
    }

Upvotes: 0

Related Questions