File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
packages/firebase-messaging-core Expand file tree Collapse file tree 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();
5252const onTokenCallbacks : Set < ( token : any ) => void > = new Set ( ) ;
5353const onNotificationTapCallbacks : Set < ( message : any ) => void > = new Set ( ) ;
5454
55- let lastActivity ;
55+ let lastActivity : WeakRef < androidx . appcompat . app . AppCompatActivity > ;
5656let requestPermissionLauncher : androidx . activity . result . ActivityResultLauncher < any > ;
5757let _resolve ;
5858
5959function register ( args : any ) {
6060 if ( ! lastActivity ) {
61- lastActivity = args . activity ;
61+ lastActivity = new WeakRef ( args . activity ) ;
6262 requestPermissionLauncher = args . activity . registerForActivityResult (
6363 new androidx . activity . result . contract . ActivityResultContracts . RequestPermission ( ) ,
6464 new androidx . activity . result . ActivityResultCallback ( {
@@ -142,8 +142,8 @@ export class MessagingCore implements IMessagingCore {
142142 Application . android . once ( 'activityCreated' , register ) ;
143143
144144 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 ) {
147147 requestPermissionLauncher ?. unregister ?.( ) ;
148148 lastActivity = undefined ;
149149 Application . android . once ( 'activityCreated' , register ) ;
You can’t perform that action at this time.
0 commit comments