Device.getLocationConsent()

Overview

Returns whether the user has accepted the location consent prompt on the device. If the user has declined to consent to location information, using Device.getDeviceLocation() may return null or undefined.

Android and Windows only

Added in version 2.1.47

Format

var hasConsent = Device.getLocationConsent();

Parameter Description Type Notes
hasConsent The returned Boolean indicating if the user has consented to location data collection. Boolean Return value

Example

Copy
/* Check location consent before retrieving GPS coordinates
 */
if (Device.getLocationConsent()) {
    Device.getDeviceLocation(function(loc) {
        if (loc) {
            View.toast(`Latitude: ${loc.latitude}, Longitude: ${loc.longitude}`);
        } else {
            View.toast("Location not available");
        }
    });
} else {
    View.toast("Location consent has not been granted.");
}