@@ -71,6 +71,30 @@ function register(args: any) {
7171 }
7272}
7373
74+ Application . android . on ( 'activityResumed' , ( args ) => {
75+ MessagingCore . _inForeground = true ;
76+ MessagingCore . appDidLaunch = true ;
77+ MessagingCore . _onResumeQueue . forEach ( ( callback ) => {
78+ callback ( ) ;
79+ } ) ;
80+ MessagingCore . _onResumeQueue . splice ( 0 ) ;
81+ } ) ;
82+
83+ Application . android . on ( 'activityPaused' , ( args ) => {
84+ MessagingCore . _inForeground = false ;
85+ } ) ;
86+
87+ Application . android . once ( 'activityCreated' , register ) ;
88+
89+ Application . android . on ( 'activityDestroyed' , ( args ) => {
90+ const activity = lastActivity ?. get ?.( ) ;
91+ if ( activity && args . activity === activity ) {
92+ requestPermissionLauncher ?. unregister ?.( ) ;
93+ lastActivity = undefined ;
94+ Application . android . once ( 'activityCreated' , register ) ;
95+ }
96+ } ) ;
97+
7498export class MessagingCore implements IMessagingCore {
7599 #native: com . google . firebase . messaging . FirebaseMessaging ;
76100 #onMessageCallback?;
@@ -109,14 +133,28 @@ export class MessagingCore implements IMessagingCore {
109133 }
110134 MessagingCore . #onResumeQueue. push ( callback ) ;
111135 }
136+
137+ static get _onResumeQueue ( ) {
138+ return this . #onResumeQueue;
139+ }
140+
112141 static #inForeground = false ;
142+ static set _inForeground ( value ) {
143+ this . #inForeground = value ;
144+ }
145+ static get _inForeground ( ) {
146+ return this . #inForeground;
147+ }
113148 static #appDidLaunch = false ;
114149 static get inForeground ( ) {
115150 return MessagingCore . #inForeground;
116151 }
117152 static get appDidLaunch ( ) {
118153 return MessagingCore . #appDidLaunch;
119154 }
155+ static set appDidLaunch ( value ) {
156+ MessagingCore . #appDidLaunch = value ;
157+ }
120158
121159 constructor ( ) {
122160 if ( defaultInstance ) {
@@ -126,30 +164,6 @@ export class MessagingCore implements IMessagingCore {
126164
127165 this . #native = com . google . firebase . messaging . FirebaseMessaging . getInstance ( ) ;
128166
129- Application . android . on ( 'activityResumed' , ( args ) => {
130- MessagingCore . #inForeground = true ;
131- MessagingCore . #appDidLaunch = true ;
132- MessagingCore . #onResumeQueue. forEach ( ( callback ) => {
133- callback ( ) ;
134- } ) ;
135- MessagingCore . #onResumeQueue. splice ( 0 ) ;
136- } ) ;
137-
138- Application . android . on ( 'activityPaused' , ( args ) => {
139- MessagingCore . #inForeground = false ;
140- } ) ;
141-
142- Application . android . once ( 'activityCreated' , register ) ;
143-
144- Application . android . on ( 'activityDestroyed' , ( args ) => {
145- const activity = lastActivity ?. get ?.( ) ;
146- if ( activity && args . activity === activity ) {
147- requestPermissionLauncher ?. unregister ?.( ) ;
148- lastActivity = undefined ;
149- Application . android . once ( 'activityCreated' , register ) ;
150- }
151- } ) ;
152-
153167 org . nativescript . firebase . messaging . FirebaseMessaging . init ( Utils . android . getApplicationContext ( ) ) ;
154168 ensureCallback ( ) ;
155169
0 commit comments