Add location-based reminders so that when you are near a place of interest, you'll get a notification.
This was created for the Treehouse iOS Techdegree Unit 9 project.
To create and save reminders, I used Core Data. I created a Reminder entity which has attributes for:
When a reminder is created, Core Location is used to start monitoring the location within a given radius. The region being monitored is assigned an identifier that matches the Reminder's unique identifier in the Core Data database so that the reminder can be fetched again later. When a user enters/exits the reminder location, CLLocationManager calls the appropriate delegate methods for locationManager(_: didEnterRegion) or locationManager(_: didExitRegion). The region identifier is used to fetch the matching reminder, and a local notification is triggered using the UserNotifications framework. The notification's message is set using the matching reminder's location name and title.
The user can choose the reminder location with a searchable MKMapView. A UISearchController is used for this. When the user starts typing in the search bar an MKLocalSearch request is run to search for nearby points of interest. After a place is chosen, the reminder location radius is rendered on the map using MKMapViewDelegate.mapView(_: renderFor) making it easy to tell how close the user has to be to trigger the reminder notification.