我有一個應用程序,它執行定期位置更新以映射用戶路徑。CLError.DeferredFailed錯誤(kCLErrorDomain代碼= 11)延期GPS更新失敗
我正在使用延遲更新。
if (CLLocationManager.deferredLocationUpdatesAvailable() == true && _isDeferingUpdates == false)
{
print("Doing refresh")
_isDeferingUpdates = true
_locationManager.allowDeferredLocationUpdatesUntilTraveled(C_GPS.ACTIVITY_UPDATE_DISTANCE, timeout: C_GPS.ACTIVITY_UPDATE_TIME)
} else
{
print("Could not refresh")
// iPhone 4S does not have deferring so must keep it always on
_locationManager.startUpdatingLocation()
}
當應用程序打開時,我每秒都會收到「正在刷新」的電話。
我的設置:
對我的plist NSLocationWhenInUseUsageDescription & & NSLocationAlwaysUsageDescription
2個按鍵具有背景模式開啓,遠程Notifcations和位置更新。
將地圖設置爲使用自行車和行人。
將手機上的所有權限設置爲yes。
您是否知道我的應用程序轉到後臺時爲什麼我的延期更新失敗的其他原因?
它從來沒有工作,蘋果文檔小於有用
DeferredFailed位置經理沒有爲 未知原因延期輸入模式。如果GPS不可用,可能會發生此錯誤,而不是 處於活動狀態,或者暫時中斷。如果在具有GPS硬件的 設備上出現此錯誤,則解決方法是再試一次。
這是我的錯誤處理程序:
func locationManager(manager: CLLocationManager, didFinishDeferredUpdatesWithError error: NSError?)
{
print("FINISHED BACKGROUND UPDATE with error \(error)")
if (error != nil)
{
print("ERROR IS VALID as CLError")
if (error!.code == CLError.LocationUnknown.rawValue)
{
print("Error: Location Unknown")
} else if (error!.code == CLError.DeferredAccuracyTooLow.rawValue)
{
print("Error: Accuracy too low")
} else if (error!.code == CLError.DeferredFailed.rawValue)
{
print("Error: Deferring Failed")
} else if (error!.code == CLError.Denied.rawValue)
{
print("Error: Denied")
} else
{
print("Error not handled")
}
}
_isDeferingUpdates = false
}
我發現這個尋找iOS 10 http://stackoverflow.com/questions/39498899/deferredlocationupdatesavailable-returns-no-in-ios-10 –
我發現這個尋找iOS 10 http://stackoverflow.com/questions/39498899/deferredlocationupdatesavailable-returns-no-in-ios-10 –