Type Event Revision Release 2024.3703 Keywords location, GPS
These are location events generated by the GPS hardware. They are only sent to the global Runtime object when the app requests them with a statement like Runtime:addEventListener( "location", locationHandler )
See the individual property documentation pages below for examples.
In the location event listener, event.errorCode should be checked in case of a location error.
To enable GPS on Android devices, you must add the following permission(s) to the build.settings
file:
settings = { android = { usesPermissions = { -- Permission to retrieve current location from the GPS "android.permission.ACCESS_FINE_LOCATION", -- Permission to retrieve current location from WiFi or cellular service "android.permission.ACCESS_COARSE_LOCATION", }, }, }
On iOS, event.errorCode will be nil
You must adjust your app’s entitlements to use location events for macOS apps. See here for details.
Location services are not currently supported on Windows. While the Corona Simulator for Windows will synthesize a fake location event for testing purposes, Windows desktop apps will not do this. As a consequence, system.hasEventSource( "location" )
true
in the Corona Simulator for Windows but false
in Windows desktop apps.