Skip to content

Commit

Permalink
Resolve request permission call when permission already exists
Browse files Browse the repository at this point in the history
Problem:
If permission is already enabled, the native call to `OneSignal.getNotifications().requestPermission(fallbackToSettings, Continue.with(...)` never suspends and the Continuation code block never runs. As a result, we would not be able to resolve the promise over the bridge.

Solution:
Before calling that method, do a permission check and return true early.
  • Loading branch information
nan-li committed Nov 6, 2023
1 parent cd95c19 commit 67d96f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions www/NotificationsNamespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export default class Notifications {
* @returns {Promise<boolean>}
*/
requestPermission(fallbackToSettings?: boolean): Promise<boolean> {
// if permission already exists, return early as the native call will not resolve
if (this.hasPermission()) {
return Promise.resolve(true);
}
let fallback = fallbackToSettings ?? false;

return new Promise<boolean>((resolve, reject) => {
Expand Down

0 comments on commit 67d96f6

Please sign in to comment.