File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
packages/firebase-messaging-core Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const onNotificationTapCallbacks: Set<(message: any) => void> = new Set();
5454
5555let lastActivity : WeakRef < androidx . appcompat . app . AppCompatActivity > ;
5656let requestPermissionLauncher : androidx . activity . result . ActivityResultLauncher < any > ;
57- let _resolve ;
57+ let _permissionQueue : { resolve : Function ; reject : Function } [ ] = [ ] ;
5858
5959function register ( args : any ) {
6060 if ( ! lastActivity ) {
@@ -63,8 +63,10 @@ function register(args: any) {
6363 new androidx . activity . result . contract . ActivityResultContracts . RequestPermission ( ) ,
6464 new androidx . activity . result . ActivityResultCallback ( {
6565 onActivityResult ( isGranted : boolean ) {
66- _resolve ?.( isGranted ? 0 : 1 ) ;
67- _resolve = undefined ;
66+ _permissionQueue . forEach ( ( callback ) => {
67+ callback . resolve ( isGranted ? 0 : 1 ) ;
68+ } ) ;
69+ _permissionQueue . splice ( 0 ) ;
6870 } ,
6971 } )
7072 ) ;
@@ -307,7 +309,10 @@ export class MessagingCore implements IMessagingCore {
307309
308310 return new Promise ( ( resolve , reject ) => {
309311 const launch = ( activity ) => {
310- _resolve = resolve ;
312+ _permissionQueue . push ( {
313+ resolve,
314+ reject,
315+ } ) ;
311316 requestPermissionLauncher . launch ( ( android as any ) . Manifest . permission . POST_NOTIFICATIONS ) ;
312317 } ;
313318
You can’t perform that action at this time.
0 commit comments