File tree 1 file changed +4
-4
lines changed
packages/firebase-messaging-core
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,13 @@ const onMessageCallbacks: Set<(message: any) => void> = new Set();
52
52
const onTokenCallbacks : Set < ( token : any ) => void > = new Set ( ) ;
53
53
const onNotificationTapCallbacks : Set < ( message : any ) => void > = new Set ( ) ;
54
54
55
- let lastActivity ;
55
+ let lastActivity : WeakRef < androidx . appcompat . app . AppCompatActivity > ;
56
56
let requestPermissionLauncher : androidx . activity . result . ActivityResultLauncher < any > ;
57
57
let _resolve ;
58
58
59
59
function register ( args : any ) {
60
60
if ( ! lastActivity ) {
61
- lastActivity = args . activity ;
61
+ lastActivity = new WeakRef ( args . activity ) ;
62
62
requestPermissionLauncher = args . activity . registerForActivityResult (
63
63
new androidx . activity . result . contract . ActivityResultContracts . RequestPermission ( ) ,
64
64
new androidx . activity . result . ActivityResultCallback ( {
@@ -142,8 +142,8 @@ export class MessagingCore implements IMessagingCore {
142
142
Application . android . once ( 'activityCreated' , register ) ;
143
143
144
144
Application . android . on ( 'activityDestroyed' , ( args ) => {
145
- const activity = args . activity ;
146
- if ( lastActivity && activity === lastActivity ) {
145
+ const activity = lastActivity ?. get ?. ( ) ;
146
+ if ( activity && args . activity === activity ) {
147
147
requestPermissionLauncher ?. unregister ?.( ) ;
148
148
lastActivity = undefined ;
149
149
Application . android . once ( 'activityCreated' , register ) ;
You can’t perform that action at this time.
0 commit comments