Skip to content

Commit

Permalink
Merge pull request #806 from OneSignal/fix/resolve_request_permission
Browse files Browse the repository at this point in the history
[fix] Android: Resolve `requestPermission` call when already granted
  • Loading branch information
nan-li committed Jan 31, 2024
2 parents cfffdce + f880e54 commit 48e8fba
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ else if (call.method.contentEquals("OneSignal#addNativeClickListener"))

private void requestPermission(MethodCall call, Result result) {
boolean fallback = (boolean) call.argument("fallbackToSettings");
// if permission already exists, return early as the method call will not resolve
if (OneSignal.getNotifications().getPermission()) {
replySuccess(result, true);
return;
}

OneSignal.getNotifications().requestPermission(fallback, Continue.with(permissionResult -> {
replySuccess(result, permissionResult.getData());
}));
Expand Down

0 comments on commit 48e8fba

Please sign in to comment.