@@ -71,6 +71,30 @@ function register(args: any) {
71
71
}
72
72
}
73
73
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
+
74
98
export class MessagingCore implements IMessagingCore {
75
99
#native: com . google . firebase . messaging . FirebaseMessaging ;
76
100
#onMessageCallback?;
@@ -109,14 +133,28 @@ export class MessagingCore implements IMessagingCore {
109
133
}
110
134
MessagingCore . #onResumeQueue. push ( callback ) ;
111
135
}
136
+
137
+ static get _onResumeQueue ( ) {
138
+ return this . #onResumeQueue;
139
+ }
140
+
112
141
static #inForeground = false ;
142
+ static set _inForeground ( value ) {
143
+ this . #inForeground = value ;
144
+ }
145
+ static get _inForeground ( ) {
146
+ return this . #inForeground;
147
+ }
113
148
static #appDidLaunch = false ;
114
149
static get inForeground ( ) {
115
150
return MessagingCore . #inForeground;
116
151
}
117
152
static get appDidLaunch ( ) {
118
153
return MessagingCore . #appDidLaunch;
119
154
}
155
+ static set appDidLaunch ( value ) {
156
+ MessagingCore . #appDidLaunch = value ;
157
+ }
120
158
121
159
constructor ( ) {
122
160
if ( defaultInstance ) {
@@ -126,30 +164,6 @@ export class MessagingCore implements IMessagingCore {
126
164
127
165
this . #native = com . google . firebase . messaging . FirebaseMessaging . getInstance ( ) ;
128
166
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
-
153
167
org . nativescript . firebase . messaging . FirebaseMessaging . init ( Utils . android . getApplicationContext ( ) ) ;
154
168
ensureCallback ( ) ;
155
169
0 commit comments