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();
54
54
55
55
let lastActivity : WeakRef < androidx . appcompat . app . AppCompatActivity > ;
56
56
let requestPermissionLauncher : androidx . activity . result . ActivityResultLauncher < any > ;
57
- let _resolve ;
57
+ let _permissionQueue : { resolve : Function ; reject : Function } [ ] = [ ] ;
58
58
59
59
function register ( args : any ) {
60
60
if ( ! lastActivity ) {
@@ -63,8 +63,10 @@ function register(args: any) {
63
63
new androidx . activity . result . contract . ActivityResultContracts . RequestPermission ( ) ,
64
64
new androidx . activity . result . ActivityResultCallback ( {
65
65
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 ) ;
68
70
} ,
69
71
} )
70
72
) ;
@@ -307,7 +309,10 @@ export class MessagingCore implements IMessagingCore {
307
309
308
310
return new Promise ( ( resolve , reject ) => {
309
311
const launch = ( activity ) => {
310
- _resolve = resolve ;
312
+ _permissionQueue . push ( {
313
+ resolve,
314
+ reject,
315
+ } ) ;
311
316
requestPermissionLauncher . launch ( ( android as any ) . Manifest . permission . POST_NOTIFICATIONS ) ;
312
317
} ;
313
318
You can’t perform that action at this time.
0 commit comments