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 May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+27-7Lines changed: 27 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -283,8 +283,13 @@ Queries the CodePush service to see whether the configured app deployment has an
283
283
284
284
This method returns a `Promise` which resolves to one of two possible values:
285
285
286
-
*`null` if there is no update available.
287
-
* A `RemotePackage` instance which represents an available update that can be inspected and/or subsequently downloaded.
286
+
1.`null` if there is no update available. This occurs in the following scenarios:
287
+
288
+
1. The configured deployment doesn't contain any releases, and therefore, nothing to update.
289
+
2. The latest release within the configured deployment is targeting a different binary version than what you're currently running (either older or newer).
290
+
3. The currently running app already has the latest release from the configured deployment, and therefore, doesn't need it again.
291
+
292
+
2. A [`RemotePackage`](#remotepackage) instance which represents an available update that can be inspected and/or subsequently downloaded.
Retrieves the metadata about the currently installed "package" (e.g. description, installation time). This can be useful for scenarios such as displaying a "what's new?" dialog after an update has been applied.
313
+
Retrieves the metadata about the currently installed "package" (e.g. description, installation time). This can be useful for scenarios such as displaying a "what's new?" dialog after an update has been applied, and checking whether there is a pending update that is waiting to be applied via a resume or restart.
309
314
310
-
This method returns a `Promise` which resolves to the `LocalPackage` instance that represents the currently running update.
315
+
This method returns a `Promise` which resolves to the [`LocalPackage`](#localpackage) instance that represents the currently running update.
311
316
312
317
Example Usage:
313
318
@@ -353,11 +358,11 @@ This method is for advanced scenarios, and is primarily useful when the followin
Synchronizes your app's JavaScript bundle and image assets with the latest release to the configured deployment. Unlike the `checkForUpdate` method, which simply checks for the presence of an update, and let's you control what to do next, `sync` handles the update check, download and installation experience for you.
361
+
Synchronizes your app's JavaScript bundle and image assets with the latest release to the configured deployment. Unlike the [checkForUpdate](#codepushcheckforupdate) method, which simply checks for the presence of an update, and let's you control what to do next, `sync` handles the update check, download and installation experience for you.
357
362
358
363
This method provides support for two different (but customizable) "modes" to easily enable apps with different requirements:
359
364
360
-
1. **Silent mode** *(the default behavior)*, which automatically downloads available updates, and applies them the next time the app restarts. This way, the entire update experience is "silent" to the end user, since they don't see any update prompt and/or "synthetic" app restarts.
365
+
1. **Silent mode** *(the default behavior)*, which automatically downloads available updates, and applies them the next time the app restarts (e.g. the OS or end user killed it, or the device was restarted). This way, the entire update experience is "silent" to the end user, since they don't see any update prompt and/or "synthetic" app restarts.
361
366
362
367
2. **Active mode**, which when an update is available, prompts the end user for permission before downloading it, and then immediately applies the update. If an update was released using the `mandatory` flag, the end user would still be notified about the update, but they wouldn't have the choice to ignore it.
codePush.sync({ updateDialog: { title:"An update is available!" } });
425
+
426
+
// Displaying an update prompt which includes the
427
+
// description associated with the CodePush release
428
+
codePush.sync({
429
+
updateDialog: {
430
+
appendReleaseDescription:true,
431
+
descriptionPrefix:"\n\nChange log:\n"
432
+
},
433
+
installMode:codePush.InstallMode.IMMEDIATE
434
+
});
435
+
436
+
420
437
```
421
438
422
439
In addition to the options, the `sync` method also accepts two optional function parameters which allow you to subscribe to the lifecycle of the `sync` "pipeline" in order to display additional UI as needed (e.g. a "checking for update modal or a download progress modal):
This method returns a `Promise` which is resolved to a `SyncStatus` code that indicates why the `sync` call succeeded. This code can be one of the following `SyncStatus` values:
448
465
449
466
*__CodePush.SyncStatus.UP_TO_DATE__*(4)* - The app is up-to-date with the CodePush server.
467
+
450
468
*__CodePush.SyncStatus.UPDATE_IGNORED__*(5)* - The app had an optional update which the end user chose to ignore. (This is only applicable when the `updateDialog` is used)
469
+
451
470
*__CodePush.SyncStatus.UPDATE_INSTALLED__*(6)* - The update has been installed and will be run either immediately after the `syncStatusChangedCallback` function returns or the next time the app resumes/restarts, depending on the `InstallMode` specified in `SyncOptions`.
452
471
453
472
If the update check and/or the subsequent download fails for any reason, the `Promise` object returned by `sync` will be rejected with the reason.
@@ -458,7 +477,8 @@ The `sync` method can be called anywhere you'd like to check for an update. That
458
477
459
478
The `checkForUpdate` and `getCurrentPackage` methods return promises, that when resolved, provide acces to "package" objects. The package represents your code update as well as any extra metadata (e.g. description, mandatory?). The CodePush API has the distinction between the following types of packages:
460
479
461
-
*[LocalPackage](#localpackage): Represents a downloaded update package that is either already running, or has been installed and is pending an app restart.
480
+
*[LocalPackage](#localpackage): Represents a downloaded update that is either already running, or has been installed and is pending an app restart.
481
+
462
482
*[RemotePackage](#remotepackage): Represents an available update on the CodePush server that hasn't been downloaded yet.
0 commit comments