如何知道用户来到iOS中的特定位置? [无论是在后台还是在前景中]

时间:2018-08-17 07:06:32

标签: ios iphone swift core-location

我有用户的当前位置。而且我可以匹配用户是否循环内的半径。

我在应用程序的前景和背景中进行过操作。但是我想在终止的应用程序中做。当用户靠近我的特定点时,一旦进入我的区域,如何弹出警报?!?

1 个答案:

答案 0 :(得分:0)

用于应用程序的后台或终止状态

/*
 *  startMonitoringSignificantLocationChanges
 *
 *  Discussion:
 *      Start monitoring significant location changes.  The behavior of this service is not affected by the desiredAccuracy
 *      or distanceFilter properties.  Locations will be delivered through the same delegate callback as the standard
 *      location service.
 *
 */
@available(iOS 4.0, *)
open func startMonitoringSignificantLocationChanges()

使用CLRegion进行GeoFencing -跟踪天气用户进入该区域内并离开该区域

  let region = CLCircularRegion(center: geotification.coordinate, radius: geotification.radius, identifier: geotification.identifier)

  region.notifyOnEntry = (geotification.eventType == .onEntry)
  region.notifyOnExit = !region.notifyOnEntry