iOS 10 introduced UNLocationNotificationTrigger
for triggering local notification based on a defined CLRegion
. Prior to iOS 10 I was using CLLocationManager
's startMonitoringForRegion
to do geofencing and send local notifications based on user location.
Can anybody tell me what the differences between these two approaches are?
With Core Location region monitoring, your app is launched into the background when the region is entered or exited. In your case you are using this background execution to post a local notification, but you could execute other code.
With a location-based UNLocalNotificationTrigger
the local notification will be posted when the region is entered but no code within your app will be executed (unless the user launches your app by tapping the notification). Also, nothing will happen when the region is exited.