Skip to content

Commit

Permalink
Check permissionRequestInProgress in onRequestPermissionsResult (Maik…
Browse files Browse the repository at this point in the history
…uB#1686)

Other flutter plugins permissions requests can end up triggering onRequestPermissionsResult, so only handle callbacks when we're expecting one to be outstanding.

This fixes a `java.lang.IllegalStateException: Reply already submitted` crash.
  • Loading branch information
nvx authored Sep 3, 2022
1 parent b707190 commit c901b4f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ public void requestPermission(@NonNull PermissionRequestListener callback) {
@Override
public boolean onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
if (permissionRequestInProgress && requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
boolean granted =
grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
callback.complete(granted);
Expand Down

0 comments on commit c901b4f

Please sign in to comment.