我目前正試圖找到一種方法,通過使用位置監控範圍在iOS上的背景標,然後觸發測距,像這樣:燈塔在iOS上
func locationManager(manager: CLLocationManager, didDetermineState state: CLRegionState, forRegion region: CLRegion) {
if (state == .Inside) {
locationManager.startRangingBeaconsInRegion((region as? CLBeaconRegion)!)
}
}
我再試圖讓API調用信標幀範圍
func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
for beacon in beacons {
let minor = beacon.minor as Int
let major = beacon.major as Int
do {
try APICall.canSeeBeacons(major, minor: minor)
} catch {
print("Error making API call")
}
}
}
然而這僅適用於約十分鐘,而手機是在後臺進行,十幾分鍾後,它不再工作,但我希望做它是連續的,以便在發現信標時始終可以進行API調用。我也有權限設置正確的鑰匙,我對我的LocationManager
您是否嘗試將單個信標放置超過十分鐘或者在10分鐘後沒有進入區域進入/退出事件時遇到問題? – Paulw11
@ Paulw11它只是區域入口,我需要應用程序在檢測到附近的信標時撥打電話 – HarryMoy
什麼班級持有您的位置管理員?應用程序委託或視圖控制器? – Paulw11