I'm a beginner programmer and Google sent me an email saying
Your app must display a prominent disclosure through a pop-up alert before your app’s location runtime permission. Based on our review, a prominent disclosure did not appear before the runtime permission. Please add a prominent disclosure before the runtime permission.
I have tried a lot of things and just cant figure out how to popup an alert before the permissions. It always pops up up after the permissions.
Here is my MainActivity :
using Android;
using Android.App;
using Android.Content;
using Android.Webkit;
using Android.OS;
using Android.Content.PM;
using Xamarin.Essentials;
using Plugin.Permissions;
[assembly: UsesPermission(Name = Manifest.Permission.AccessFineLocation)]
[assembly: UsesPermission(Name = Manifest.Permission.AccessCoarseLocation)]
[assembly: UsesPermission(Name = Manifest.Permission.AccessBackgroundLocation)]
[assembly: UsesPermission(Name = Manifest.Permission.LocationHardware)]
[assembly: UsesPermission(Name = Manifest.Permission.Internet)]
namespace TqlSaldo.Droid
{
[Activity(Label = "TqlSaldo", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
public class WebViewLocationActivity : Activity
{
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
Plugin.Permissions.PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults); base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
protected override void OnCreate(Bundle bundle)
{
Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = this;
base.OnCreate(bundle);
if (CheckSelfPermission(Manifest.Permission.AccessCoarseLocation) != (int)Permission.Granted)
{
RequestPermissions(new string[] { Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessFineLocation }, 0);
}
Xamarin.Essentials.Platform.Init(this, bundle);
var webview = new WebView(this);
webview.Settings.JavaScriptEnabled = true;
webview.Settings.SetGeolocationEnabled(true);
webview.SetWebChromeClient(new MyWebChromeClient(this));
webview.LoadUrl("https://clientescentro.tanquelleno.com/Mapa/IndexLimite");
SetContentView(webview);
}
}
public class MyWebChromeClient : WebChromeClient
{
private readonly Context _context;
public MyWebChromeClient(Context context)
{
_context = context;
}
public override void OnGeolocationPermissionsShowPrompt(string origin, GeolocationPermissions.ICallback callback)
{
const bool remember = true;
var builder = new AlertDialog.Builder(_context);
builder.SetTitle("Localizador de Estaciones")
.SetMessage(string.Format("Por favor acepta lalocalizacion:", origin))
.SetPositiveButton("Aceptar", (sender, args) => callback.Invoke(origin, true, remember))
.SetNegativeButton("Denegar", (sender, args) => callback.Invoke(origin, false, remember));
var alert = builder.Create();
alert.Show();
}
}
}
And here's a screenshot of the GPS popup.

The permissions are running fine, I just need help with the prominent disclosure BEFORE the ask of permissions