Post

Replies

Boosts

Views

Activity

getDeliveredNotifications does not return notifications triggered by UNLocationNotificationTrigger
I am trying to retrieve delivered notifications using UNUserNotificationCenter.getDeliveredNotifications(completionHandler:), but I have encountered an issue: Notifications triggered by UNTimeIntervalNotificationTrigger or UNCalendarNotificationTrigger appear in the delivered list. However, notifications triggered by UNLocationNotificationTrigger do not appear in the list. Here is the code I use to fetch delivered notifications: UNUserNotificationCenter.current().getDeliveredNotifications { notifications in for notification in notifications { print("Received notification: \(notification.request.identifier)") } } The notification is scheduled as follows: let center = UNUserNotificationCenter.current() let content = UNMutableNotificationContent() content.title = "Test Notification" content.body = "This is a location-based notification." content.sound = .default let coordinate = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) // Example coordinates let region = CLCircularRegion(center: coordinate, radius: 100, identifier: "TestRegion") region.notifyOnEntry = true region.notifyOnExit = false let trigger = UNLocationNotificationTrigger(region: region, repeats: false) let request = UNNotificationRequest(identifier: "LocationTest", content: content, trigger: trigger) center.add(request) { error in if let error = error { print("Error adding notification: \(error.localizedDescription)") } } Why does getDeliveredNotifications not return notifications that were triggered using UNLocationNotificationTrigger? How can I retrieve such notifications after they have been delivered?
1
0
51
3w