is there a function in swift which is similar to proximityAlert function in android. i am building an app in which, i need to trigger a local notification when the user enters a specific location with a specified radius. any other alternative solutions are also welcome.
Yes of course. You want to create a geofence. Take a look at the location manager (CLLocationManager
). Specifically you want to create a CLCircularRegion
and use the location manager method startMonitoringForRegion
.
That doesn't get you a local notification directly. Instead the location manager calls it's delegate (including launching your app if it needs to and you've asked for and gotten permission from the user to do so.)
When you enter the specified radius your locationManager:didEnterRegion:
method will be called (possibly from the background). It will even launch your app if you want it to.
You can then generate and send a local notification if you want one.