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.
* Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code.
14
-
* This happends only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
14
+
* This happens only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
15
15
*/
16
16
getPendingPackage(): Promise<ILocalPackage>;
17
17
/**
@@ -102,7 +102,7 @@ declare class CodePush implements CodePushCapacitorPlugin {
102
102
getCurrentPackage(): Promise<ILocalPackage>;
103
103
/**
104
104
* Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code.
105
-
* This happends only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
105
+
* This happens only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
106
106
*/
107
107
getPendingPackage(): Promise<ILocalPackage>;
108
108
/**
@@ -131,14 +131,10 @@ declare class CodePush implements CodePushCapacitorPlugin {
131
131
* - If no update is available on the server, the syncCallback will be invoked with the SyncStatus.UP_TO_DATE.
132
132
* - If an error occurs during checking for update, downloading or installing it, the syncCallback will be invoked with the SyncStatus.ERROR.
133
133
*
134
-
* @param syncCallback Optional callback to be called with the status of the sync operation.
135
-
* The callback will be called only once, and the possible statuses are defined by the SyncStatus enum.
136
134
* @param syncOptions Optional SyncOptions parameter configuring the behavior of the sync operation.
137
135
* @param downloadProgress Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
138
-
* @param syncErrback Optional errback invoked if an error occurs. The callback will be called only once
* Convenience method for installing updates in one method call.
144
140
* This method is provided for simplicity, and its behavior can be replicated by using window.codePush.checkForUpdate(), RemotePackage's download() and LocalPackage's install() methods.
0 commit comments