Skip to content

Commit

Permalink
fix(android): add error handling for POST_NOTIFICATIONS permission re…
Browse files Browse the repository at this point in the history
…quest (#1135)
  • Loading branch information
sanduluca authored Oct 31, 2024
1 parent 6b06c9f commit ae2953b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,17 @@ public void requestPermission(Promise promise) {
.setRequestPermissionCallback(
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));

activity.requestPermissions(
new String[] {Manifest.permission.POST_NOTIFICATIONS},
Notifee.REQUEST_CODE_NOTIFICATION_PERMISSION,
this);
try {
activity.requestPermissions(
new String[] {Manifest.permission.POST_NOTIFICATIONS},
Notifee.REQUEST_CODE_NOTIFICATION_PERMISSION,
this);
} catch (Exception e) {
Logger.d(
"requestPermission",
"Failed to request POST_NOTIFICATIONS permission: " + e.getMessage());
NotifeeReactUtils.promiseResolver(promise, e);
}
}

@ReactMethod
Expand Down

0 comments on commit ae2953b

Please sign in to comment.