How can one check which type of Geolocation is enabled/granted on Android? particularly background.
In Sentry I can see this information but the Geolocation plugin doesn’t distinguish which one is granted.
How can one check which type of Geolocation is enabled/granted on Android? particularly background.
In Sentry I can see this information but the Geolocation plugin doesn’t distinguish which one is granted.
If you are using the Capacitor Geolocation plugin, you can try this:
const checkAppPermissions = async () => {
const permissions = await Geolocation.checkPermissions()
if (permissions.location === 'granted') {
console.log("you have both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions!")
} else if (permissions.coarseLocation === 'granted') {
console.log("you have ACCESS_COARSE_LOCATION permission only!")
} else {
console.log("you don't have any permission!")
}
}
What about the background? which is what I’m interested in
They don’t mention background permission in their documentation. They only have location and coarselocation permissions in GeolocationPermissionType.
export declare type GeolocationPermissionType = 'location' | 'coarseLocation';
Maybe you should look for another plugin
I have, no luck. even the plugins performing background task checks for location only, they do not specify or give the ability to check what was granted
Capacitor’s Geolocation plugin doesn’t work in the background, so that’s why it doesn’t request nor provide the status of background geolocation permission.
If you are using a background geolocation plugin and it doesn’t provide that information, you can try to request the feature to the plugin author, or you can search for a permissions plugin (there is a cordova one that should work, not sure if there is a Capacitor one too)