Skip to content

Commit

Permalink
fix(firebase_messaging, android): ensure only messaging permission re…
Browse files Browse the repository at this point in the history
…quest is processed (#9486)
  • Loading branch information
russellwheatley committed Sep 8, 2022
1 parent 639cab7 commit 5b31e71
Showing 1 changed file with 9 additions and 8 deletions.
Expand Up @@ -12,7 +12,7 @@

class FlutterFirebasePermissionManager implements PluginRegistry.RequestPermissionsResultListener {

private final int permissionCode = 24;
private final int permissionCode = 240;
@Nullable private RequestPermissionsSuccessCallback successCallback;
private boolean requestInProgress = false;

Expand All @@ -24,15 +24,16 @@ interface RequestPermissionsSuccessCallback {
@Override
public boolean onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
requestInProgress = false;
if (requestCode != permissionCode) {
if (requestInProgress && requestCode == permissionCode && this.successCallback != null) {
requestInProgress = false;
boolean granted =
grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;

this.successCallback.onSuccess(granted ? 1 : 0);
return true;
} else {
return false;
}

int grantResult = grantResults[0];
assert this.successCallback != null;
this.successCallback.onSuccess(grantResult == PackageManager.PERMISSION_GRANTED ? 1 : 0);
return true;
}

@RequiresApi(api = 33)
Expand Down

0 comments on commit 5b31e71

Please sign in to comment.