From 9680d81e187841dcf452b229db13f8dbace0a01b Mon Sep 17 00:00:00 2001 From: Nan Date: Mon, 6 Nov 2023 12:19:11 -0800 Subject: [PATCH] Resolve request permission call when permission already exists 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. --- src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.ts b/src/index.ts index f8f5a265..ad0223ab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -413,6 +413,10 @@ export namespace OneSignal { if (!isNativeModuleLoaded(RNOneSignal)) { return Promise.reject(new Error('OneSignal native module not loaded')); } + // if permission already exists, return early as the native call will not resolve + if (hasPermission()) { + return Promise.resolve(true); + } return RNOneSignal.requestNotificationPermission(fallbackToSettings); }