0

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

jat
  • 183
  • 3
  • 14
  • 2
    Please read https://developer.apple.com/documentation/usernotifications/handling_notifications_and_notification-related_actions – vadian Sep 06 '21 at 07:15

1 Answers1

0

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()
        
    }
jat
  • 183
  • 3
  • 14