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

fix permission requests on pre-M android #19734

Closed
Closed
Changes from all commits
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 @@ -86,17 +86,17 @@ public void shouldShowRequestPermissionRationale(final String permission, final
}

/**
* Request the given permission. successCallback is called with true if the permission had been
* granted, false otherwise. For devices before Android M, this instead checks if the user has
* the permission given or not.
* Request the given permission. successCallback is called with GRANTED if the permission had been
* granted, DENIED or NEVER_ASK_AGAIN otherwise. For devices before Android M, this checks if the user has
* the permission given or not and resolves with GRANTED or DENIED.
* See {@link Activity#checkSelfPermission}.
*/
@ReactMethod
public void requestPermission(final String permission, final Promise promise) {
Context context = getReactApplicationContext().getBaseContext();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
promise.resolve(context.checkPermission(permission, Process.myPid(), Process.myUid()) ==
PackageManager.PERMISSION_GRANTED);
PackageManager.PERMISSION_GRANTED ? GRANTED : DENIED);
return;
}
if (context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
Expand Down