基本上,我想发生的是当用户启动应用程序时,执行“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)
如何设置它,使地理围栏自动清除,并根据用户的位置设置新的?
1条答案
按热度按时间jhiyze9q1#
这个应该可以