Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt user before allowing location access #9

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -208,7 +209,18 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
requestPermissions(Collections.singletonList(Manifest.permission.ACCESS_FINE_LOCATION));

} else {
callback.invoke(origin, true, false);
String alertMessage = String.format("Allow this app to use your location?");
AlertDialog.Builder builder = new AlertDialog.Builder(this.mWebView.getContext());
builder.setMessage(alertMessage);
builder.setCancelable(false);
builder.setPositiveButton("Allow", (dialog, which) -> {
callback.invoke(origin, true, false);
});
builder.setNegativeButton("Don't allow", (dialog, which) -> {
callback.invoke(origin, false, false);
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
tommasini marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down