MobileLocation crashes without network

If there is no access to the web MobileLocation crashes. How can I first check if there is a connection?

You can use the Reachability class in iOSKit:

Hi Jason, thanks for your reaction.

I implemented this, but success is always true. I don’t doubt I do something wrong…

declare function SCNetworkReachabilityCreateWithName lib “SystemConfiguration” (allocator as ptr, str as CString) as ptr
dim t as Text = “”
dim ReachabilityRef as Ptr = SCNetworkReachabilityCreateWithName(Nil, t.ToCString(xojo.Core.TextEncoding.UTF8))

dim reachableFlags as UInt32
declare function SCNetworkReachabilityGetFlags lib “SystemConfiguration” (target as ptr, byref flags as UInt32) as Boolean
dim success as Boolean = SCNetworkReachabilityGetFlags(ReachabilityRef, reachableFlags)
if success then
MessageBox “yes”
messageBox “no”
end if

return success

It would help to know at what point you get the crash and whether you can an exception and what that is?

I have an app that uses MobileLocation and it doesn’t crash with no internet. Are you checking the AuthorizationState property before calling Start?


Hi Jason, I was not able to react for some time. Sorry.

It is not MobileLocation, but MapView that causes the crash.
If I enable the Flight mode to have no access to the web the app crashes.
So I tried your suggestion, see above. But the result is always TRUE.

Solved with Reachability!