首页 > 解决方案 > 如何知道用户来到 iOS 中的特定位置?[既不是在背景中也不是在前景中]

问题描述

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

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

标签: iosiphoneswiftcore-location

解决方案


对于应用程序的背景或终止状态

/*
 *  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 进行地理围栏- 跟踪天气用户进入该区域并离开该区域

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

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

推荐阅读