Hi all.
I created a class based on Erel Location example. It works fine but today I got an error
LocManager_LocationError The operation couldn’t be completed. (kCLErrorDomain error 1.)
Despite this error Lat / Long are correct and it only happens once.
I don't quite undertand what domain this error is talking about?
Here is a code of my class
Thanks
P.S. I Google it and I found this article https://stackoverflow.com/questions...-couldn-t-be-completed-kclerrordomain-error-1
"This error occurs if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but don't have a default location set. I'm sure there are other causes as well though." Please have a look at this thread which i found, as it could be useful stackoverflow.com/q/1409141/4056108
– chirag90
Mar 30, 2015 at 15:41
I was connected to the user's iPhone via Google meeting when we both (he is my boss) discussed what was done in this current version so the user wasn't asked for a Location permission. We ran the app for the first time.
That's my be a reason why this error occured. But on my iPhones (I have iPhone 7 and 11) on the first time I always asked about this permission.
I created a class based on Erel Location example. It works fine but today I got an error
LocManager_LocationError The operation couldn’t be completed. (kCLErrorDomain error 1.)
Despite this error Lat / Long are correct and it only happens once.
I don't quite undertand what domain this error is talking about?
Here is a code of my class
B4X:
Sub Class_Globals
Public LocManager As LocationManager
Public strHeading As String,blnEnable As Boolean
Public strAltitude As String,strBearing As String,strLL As String
Public strSpeed As String,strTime As String,strAccuracy As String
Public Latitude As Double,Longitude As Double
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
' If LocManager.IsAuthorized=False Then
LocManager.Initialize("LocManager")
' End If
End Sub
public Sub LocManager_AuthorizationStatusChanged (Status As Int)
Try
If LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_DENIED Then
Log("AUTHORIZATION_DENIED")
blnEnable=False
Else if LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_RESTRICTED Then
Log("AUTHORIZATION_RESTRICTED")
blnEnable=False
Else
blnEnable=True
End If
Main.IsGPSOk=blnEnable
StartLocationUpdates
Catch
Log("LocManager_AuthorizationStatusChanged " & LastException.description)
Main.modFun.ShowError("clsGPS_LocManager_AuthorizationStatusChanged " & LastException.description)
End Try
End Sub
public Sub StartLocationUpdates
Try
'if the user allowed us to use the location service or if we never asked the user before then we call LocationManager.Start.
If LocManager.IsAuthorized Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED Then
LocManager.Start(0)
End If
LocManager.StartHeading
Catch
Log("StartLocationUpdates " & LastException.description)
Main.modFun.ShowError("clsGPS_StartLocationUpdates " & LastException.description)
End Try
End Sub
Public Sub LocManager_HeadingChanged (MagneticHeading As Double, TrueHeading As Double)
Try
If TrueHeading >= 0 Then
strHeading = NumberFormat(TrueHeading, 1, 0) & Chr(176) & " (true north)"
Else
strHeading = NumberFormat(MagneticHeading, 1, 0) & Chr(176) & " (magnetic)"
End If
Catch
Log("LocManager_HeadingChanged " & LastException.description)
Main.modFun.ShowError("clsGPS_LocManager_HeadingChanged " & LastException.description)
End Try
End Sub
public Sub LocManager_AllowCalibration As Boolean
Return True
End Sub
public Sub LocManager_LocationError
Log("Error: " & LastException.description)
Main.modFun.ShowError("LocManager_LocationError " & LastException.description )
End Sub
public Sub LocManager_LocationChanged (Location1 As Location)
Try
If Location1.VerticalAccuracy >= 0 Then
strAltitude = NumberFormat(Location1.Altitude, 1, 1) & "m"
Else
strAltitude = "N/A"
End If
strBearing = ValueOrNA (Location1.Bearing, 1, Chr(176))
If Location1.Accuracy >= 0 Then
strLL = NumberFormat(Location1.Latitude, 2, 4) & " / " & NumberFormat(Location1.Longitude, 2, 4)
Latitude=NumberFormat(Location1.Latitude, 2, 4)
Longitude=NumberFormat(Location1.Longitude, 2, 4)
Else
strLL = "N/A"
Latitude=0
Longitude=0
End If
strSpeed = ValueOrNA(Location1.Speed, 1, "m/s")
strTime = DateTime.Time(Location1.Time)
strAccuracy = ValueOrNA(Location1.Accuracy, 2, "m")
Catch
Log("LocManager_LocationChanged " & LastException.description)
Main.modFun.ShowError("clsGPS_LocManager_LocationChanged " & LastException.description)
End Try
End Sub
Private Sub ValueOrNA(value As Double, NumberOfFractions As Int, unit As String) As String
Try
If value < 0 Then
Return "N/A"
Else
Return NumberFormat(value, 1, NumberOfFractions) & unit
End If
Catch
Log("ValueOrNA " & LastException.description)
Main.modFun.ShowError("clsGPS_ValueOrNA " & LastException.description)
Return "Error"
End Try
End Sub
public Sub CheckGPS As Boolean
Try
Return Main.IsGPSOk
Catch
Log("CheckGPS " & LastException.Description)
Main.modFun.ShowError("SimpleCamera_CheckGPS " & LastException.description)
Return False
End Try
End Sub
Thanks
P.S. I Google it and I found this article https://stackoverflow.com/questions...-couldn-t-be-completed-kclerrordomain-error-1
"This error occurs if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but don't have a default location set. I'm sure there are other causes as well though." Please have a look at this thread which i found, as it could be useful stackoverflow.com/q/1409141/4056108
– chirag90
Mar 30, 2015 at 15:41
I was connected to the user's iPhone via Google meeting when we both (he is my boss) discussed what was done in this current version so the user wasn't asked for a Location permission. We ran the app for the first time.
That's my be a reason why this error occured. But on my iPhones (I have iPhone 7 and 11) on the first time I always asked about this permission.
Last edited: