基本上我想要发生的事情是当用户启动应用程序时执行“getNearbyLocations”。此代码已经到位。然后我们清除所有现有的围栏并为最近的商店设置新的围栏。这样,如果用户接近商店,地理围栏就会启动应用程序,然后我们可以使用lat / long然后签入。在代码中,我目前的lat / long是硬编码的:
//Location info for check -in
var latitude: CLLocationDegrees = 32.991652
var longitude: CLLocationDegrees = -96.8511617
var center: CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var radius: CLLocationDistance = CLLocationDistance(10.0)
var identifier: String = "storeID"
var geoRegion: CLCircularRegion = CLCircularRegion(center: center, radius: radius, identifier: identifier)
geoRegion.notifyOnEntry = true
geoRegion.notifyOnExit = false
// Core Location manager
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
manager.startMonitoringForRegion(geoRegion)
如何进行设置,以便根据用户位置自动清除地理围栏并设置新地理位置?