I’m going through a difficulty with geofencing occasions in my app. When the app is killed and never opened for two–3 days, the geofencing occasion is just not triggering after I re-enter the geofenced space. I’ve made certain that every one essential permissions (location, background refresh, and so forth.) are correctly set within the app settings.
Has anybody else skilled this? Is there an answer or workaround to make sure that geofencing works as anticipated even after the app has been killed for a number of days?
startMonitoringSignificantLocationChanges additionally talked about in applicationWillTerminate Technique.
func createRegion(latitude :Double , longitude : Double, radius : Double) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy HH:mm:ss"
let date = dateFormatter.string(from: Date())
let geofenceRegionCenter = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
let geofenceRegion = CLCircularRegion(middle: geofenceRegionCenter, radius: radius, identifier: "First")
geofenceRegion.notifyOnEntry = true
geofenceRegion.notifyOnExit = true
locationManager.startMonitoring(for: geofenceRegion)
}
func locationManager(_ supervisor: CLLocationManager, didEnterRegion area: CLRegion) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy HH:mm:ss"
let date = dateFormatter.string(from: Date())
self.isEnter = true
let latitude = supervisor.location?.coordinate.latitude ?? 0.00
let longitude = supervisor.location?.coordinate.longitude ?? 0.00
}
func locationManager(_ supervisor: CLLocationManager, didExitRegion area: CLRegion) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy HH:mm:ss"
let date = dateFormatter.string(from: Date())
self.isEnter = false
let latitude = supervisor.location?.coordinate.latitude ?? 0.00
let longitude = supervisor.location?.coordinate.longitude ?? 0.00
}