This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -178,9 +178,7 @@ async function notifyApplicationReadyInternal() {
178
178
return statusReport ;
179
179
}
180
180
181
- async function tryReportStatus ( statusReport ) {
182
- if ( ! statusReport ) return ;
183
-
181
+ async function tryReportStatus ( statusReport , resumeListener ) {
184
182
const config = await getConfiguration ( ) ;
185
183
const previousLabelOrAppVersion = statusReport . previousLabelOrAppVersion ;
186
184
const previousDeploymentKey = statusReport . previousDeploymentKey || config . deploymentKey ;
@@ -204,9 +202,23 @@ async function tryReportStatus(statusReport) {
204
202
}
205
203
206
204
NativeCodePush . recordStatusReported ( statusReport ) ;
205
+ resumeListener && AppState . removeEventListener ( "change" , resumeListener ) ;
207
206
} catch ( e ) {
208
207
log ( `Report status failed: ${ JSON . stringify ( statusReport ) } ` ) ;
209
208
NativeCodePush . saveStatusReportForRetry ( statusReport ) ;
209
+ // Try again when the app resumes
210
+ if ( ! resumeListener ) {
211
+ resumeListener = async ( newState ) => {
212
+ if ( newState !== "active" ) return ;
213
+ const refreshedStatusReport = await NativeCodePush . getNewStatusReport ( ) ;
214
+ if ( refreshedStatusReport ) {
215
+ tryReportStatus ( refreshedStatusReport , resumeListener ) ;
216
+ } else {
217
+ AppState . removeEventListener ( "change" , resumeListener ) ;
218
+ }
219
+ } ;
220
+ AppState . addEventListener ( "change" , resumeListener ) ;
221
+ }
210
222
}
211
223
}
212
224
You can’t perform that action at this time.
0 commit comments