Region(CLRegion) Based Notifications Even When the App is not Running at all
Well, this answer is not a quick one but Apple has introduced new concept in UILocalNotification. It is not required to send a push notification, iOS will automatically show a local notification when user enter/exits geographical area CLRegion
. From iOS 8 and later, we can schedule a local notification based on location not by setting fireDate
property.
let localNotification = UILocalNotification()
localNotification.alertTitle = "Hi there"
localNotification.alertBody = "you are here"
let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: 4.254, longitude: 88.25), radius: CLLocationDistance(100), identifier: "")
region.notifyOnEntry = true
region.notifyOnExit = false
localNotification.region = region
localNotification.timeZone = NSTimeZone.localTimeZone()
localNotification.soundName = UILocalNotificationDefaultSoundName
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
Here are more details from Apple.