I have an application Ionic Capacitor Angular that is simply getting the GeoLocation and displaying the lat lng on screen
async ngOnInit(){
await Geolocation.getCurrentPosition({
enableHighAccuracy: true
}).then((resp) => {
this.latitude = resp.coords.latitude;
this.longitude = resp.coords.longitude;
this.options = {
center: { lat: this.latitude, lng: this.longitude},
zoom: 17
};
}).catch((error) => {
console.log('Error getting location', error);
});
}
This runs perfectly fine in the browser with Ionic Serve. I have also successfully launched it on a device(Samsung S9) which is Android V9 (knox api level 27). However when I run it on a (Samsung S21 Ultra) which is Android V11 (knox api level 33)
I have the following within the AndroidManfiest.xml of the app
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
I see this in the documentation
Caution: If your app targets Android 11 (API level 30) or higher, the system enforces this best practice [ *asking for foreground and background access in separate requests* ]. If you request a foreground location permission and the background location permission at the same time, the system ignores the request and doesn’t grant your app either permission
I have not been able to find a resolution to this issue. Can someone please help provide some insight. Again this is actual hardware and not an emulator.