From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)

New in 2016r2

An iOSLocation allows the user to request location coordinates and updates from the device.

AuthorizationChanged LocationChanged
Accuracy Enabled
AuthorizationState fa-lock-32.png Handle fa-lock-32.png
RequestAlwaysAuthorization RequestInUseAuthorization
Accuracies AuthorizationStates


Use the Debug ↠ Location menu in the iOS Simulator to provide fake locations for testing.

Initial Setup

In the Open event handler of the view, you will need to initialize the location like this:

If MyLocation.AuthorizationState = iOSLocation.AuthorizationStates.AuthorizedWhenInUse Then
' we've got our requested authorization state, start getting LocationChanged events
MyLocation.Enabled = True
' we don't have authorization yet, so ask for it
End If

Sample plist

In addition to requesting authorization, you'll also need to provide a plist file specifying the message to display when authorization is requested. An example plist is below. Save it to a file called iOSLocation.plist and drag it into your iOS project to automatically include it with the app:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
	<string>This app needs access to your location while running.</string>

See Also