This is my code for the didEnterRegion
function. Problem is that the notification triggers while entering as well as exiting. What can I do to trigger the notification only when the user enters the location ?
func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertBody = "you've entered rohini sector -8"
localNotification.region = region
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
NSLog("Entering region")
}
You don't need to specify the region in the local notification. You already know that the device is inside the region, because you had a call to didEnterRegion
- specifying the region on the notification is redundant - You can simply post the notification without the region specified.