Copy link to clipboard
Copied
Hi,
I just saw that, with AIR 28, we need to ask permission to the user within the app for Geolocation.
I read the example in the AIR 28 Release Note but it's only about Camera.
Does someone could help me and tell me all the steps to ask the user to allow the geolocation please ?
Do I only have to put it in AS3 code ?
If so, is it something like this ? :
var _userGeo2 = new Geolocation()
if (Geolocation.isSupported){
if (Geolocation.permissionStatus != PermissionStatus.GRANTED){
_userGeo2.addEventListener(PermissionEvent.PERMISSION_STATUS, function(e:PermissionEvent):void {
if (e.status == PermissionStatus.GRANTED) {
// WHAT SHOUD I PUT HERE ????
}
else {
// permission denied
}
});
Do I have to change something in the xml file as well of can I just let this line ?
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
in my experience, it doesn't work to request permission after a user has denied it on app start-up, but it wouldn't hurt to try.
check for permission, if granted proceed; if not, don't try to utilize geolocation.
Copy link to clipboard
Copied
yes, that xml needs to be in your app descriptor.
Copy link to clipboard
Copied
OK, but what should I put on the line
"WHAT SHOUD I PUT HERE ???"
Copy link to clipboard
Copied
Hmm I think I should also put
try
{
_userGeo2
.requestPermission();
}
No?
Copy link to clipboard
Copied
in my experience, it doesn't work to request permission after a user has denied it on app start-up, but it wouldn't hurt to try.
check for permission, if granted proceed; if not, don't try to utilize geolocation.