location (GPS)

Type Event
Dispatch chain Runtime
Revision 2017.3060
Keywords location, GPS

Overview

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 pages for the individual properties for examples.

Gotchas

In the location event listener, event.errorCode should be checked in case of a location error. This flag will be non-nil if the user disables location services for the app on iOS.

Android

To enable GPS on Android devices, you must add the following permission 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",
        },
    },
}

macOS

You must adjust your app's entitlements to use location events for macOS apps. See here for details.

Properties

event.time