You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+22-15Lines changed: 22 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -415,6 +415,10 @@ While the `sync` method tries to make it easy to perform silent and active updat
415
415
416
416
-__updateTitle__*(String)* - The text used as the header of an update notification that is displayed to the end user. Defaults to `"Update available"`.
417
417
418
+
-__onSyncStatusChanged__*(`SuccessCallback<SyncStatus>`)* - A custom callback that is called when the `SyncStatus` changes.
419
+
420
+
-__onSyncError__*(`ErrorCallback`)* - A custom callback that is called on a sync process error.
421
+
418
422
Example Usage:
419
423
420
424
```javascript
@@ -441,26 +445,29 @@ codePush.sync({
441
445
installMode:InstallMode.IMMEDIATE
442
446
});
443
447
444
-
// Silently check for the update, but
445
-
// display a custom downloading UI
446
-
// via the SyncStatus and DownloadProgress callbacks
// Update "downloading" modal with current download %
461
451
//console.log("Downloading " + downloadProgress.receivedBytes + " of " + downloadProgress.totalBytes);
462
452
}
463
453
}
454
+
455
+
// Silently check for the update, but
456
+
// display a custom downloading UI
457
+
// via the SyncStatus and DownloadProgress callbacks
458
+
codePush.sync(null, downloadProgress)
459
+
.then(
460
+
(status) => {
461
+
switch (status) {
462
+
caseSyncStatus.DOWNLOADING_PACKAGE:
463
+
// Show "downloading" modal
464
+
break;
465
+
caseSyncStatus.INSTALLING_UPDATE:
466
+
// Hide "downloading" modal
467
+
break;
468
+
}
469
+
}
470
+
);
464
471
```
465
472
466
473
The `sync` method can be called anywhere you'd like to check for an update. That could be in the `deviceready` event handler, the `click` event of a button, in the callback of a periodic timer, or whatever else makes sense for your needs. Just like the `checkForUpdate` method, it will perform the network request to check for an update in the background, so it won't impact your UI thread and/or JavaScript thread's responsiveness.
0 commit comments