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.
// and therefore, it doesn't make sense initializing
384
388
// the JS interface when it wouldn't work anyways.
385
389
if(NativeCodePush){
386
-
CodePush={
387
-
AcquisitionSdk: Sdk,
388
-
checkForUpdate,
389
-
getConfiguration,
390
-
getCurrentPackage,
391
-
log,
392
-
notifyApplicationReady,
393
-
restartApp,
394
-
setUpTestDependencies,
395
-
sync,
396
-
InstallMode: {
397
-
IMMEDIATE: NativeCodePush.codePushInstallModeImmediate,// Restart the app immediately
398
-
ON_NEXT_RESTART: NativeCodePush.codePushInstallModeOnNextRestart,// Don't artificially restart the app. Allow the update to be "picked up" on the next app restart
399
-
ON_NEXT_RESUME: NativeCodePush.codePushInstallModeOnNextResume// Restart the app the next time it is resumed from the background
400
-
},
401
-
SyncStatus: {
402
-
CHECKING_FOR_UPDATE: 0,
403
-
AWAITING_USER_ACTION: 1,
404
-
DOWNLOADING_PACKAGE: 2,
405
-
INSTALLING_UPDATE: 3,
406
-
UP_TO_DATE: 4,// The running app is up-to-date
407
-
UPDATE_IGNORED: 5,// The app had an optional update and the end-user chose to ignore it
408
-
UPDATE_INSTALLED: 6,// The app had an optional/mandatory update that was successfully downloaded and is about to be installed.
409
-
SYNC_IN_PROGRESS: 7,// There is an ongoing "sync" operation in progress.
410
-
UNKNOWN_ERROR: -1
411
-
},
412
-
DEFAULT_UPDATE_DIALOG: {
413
-
appendReleaseDescription: false,
414
-
descriptionPrefix: " Description: ",
415
-
mandatoryContinueButtonLabel: "Continue",
416
-
mandatoryUpdateMessage: "An update is available that must be installed.",
417
-
optionalIgnoreButtonLabel: "Ignore",
418
-
optionalInstallButtonLabel: "Install",
419
-
optionalUpdateMessage: "An update is available. Would you like to install it?",
420
-
title: "Update available"
421
-
}
390
+
CodePush={
391
+
AcquisitionSdk: Sdk,
392
+
checkForUpdate,
393
+
getConfiguration,
394
+
getCurrentPackage,
395
+
getUpdateMetadata,
396
+
log,
397
+
notifyAppReady: notifyApplicationReady,
398
+
notifyApplicationReady,
399
+
restartApp,
400
+
setUpTestDependencies,
401
+
sync,
402
+
InstallMode: {
403
+
IMMEDIATE: NativeCodePush.codePushInstallModeImmediate,// Restart the app immediately
404
+
ON_NEXT_RESTART: NativeCodePush.codePushInstallModeOnNextRestart,// Don't artificially restart the app. Allow the update to be "picked up" on the next app restart
405
+
ON_NEXT_RESUME: NativeCodePush.codePushInstallModeOnNextResume// Restart the app the next time it is resumed from the background
406
+
},
407
+
SyncStatus: {
408
+
CHECKING_FOR_UPDATE: 0,
409
+
AWAITING_USER_ACTION: 1,
410
+
DOWNLOADING_PACKAGE: 2,
411
+
INSTALLING_UPDATE: 3,
412
+
UP_TO_DATE: 4,// The running app is up-to-date
413
+
UPDATE_IGNORED: 5,// The app had an optional update and the end-user chose to ignore it
414
+
UPDATE_INSTALLED: 6,// The app had an optional/mandatory update that was successfully downloaded and is about to be installed.
415
+
SYNC_IN_PROGRESS: 7,// There is an ongoing "sync" operation in progress.
Copy file name to clipboardExpand all lines: README.md
+33-16Lines changed: 33 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -378,7 +378,7 @@ When you require `react-native-code-push`, the module object provides the follow
378
378
379
379
* [checkForUpdate](#codepushcheckforupdate): Asks the CodePush service whether the configured app deployment has an update available.
380
380
381
-
* [getCurrentPackage](#codepushgetcurrentpackage): Retrieves the metadata about the currently installed update (e.g. description, installation time, size).
381
+
* [getUpdateMetadata](#codepushgetupdatemetadata): Retrieves the metadata for an installed update (e.g. description, mandatory).
382
382
383
383
* [notifyApplicationReady](#codepushnotifyapplicationready): Notifies the CodePush runtime that an installed update is considered successful. If you are manually checking for and installing updates (i.e. not using the [sync](#codepushsync) method to handle it all for you), then this method **MUST** be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts.
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 or checking whether there is a pending update that is waiting to be applied via a resume or restart.
426
+
Retrieves the metadata for an installed update (e.g. description, mandatory) whose state matches the specified `updateState` parameter. This can be useful for scenarios such as displaying a "what's new?" dialog after an update has been applied or checking whether there is a pending update that is waiting to be applied via a resume or restart. For more details about the possible update states, and what they represent, refer to the [UpdateState reference](#updatestate).
427
427
428
428
This method returns a `Promise` which resolves to one of two possible values:
429
429
430
-
1. `null` if the app is currently running the JS bundle from the binary and not a CodePush update. This occurs in the following scenarios:
430
+
1. `null` if an update with the specified state doesn't currently exist. This occurs in the following scenarios:
431
431
432
-
1. The end-user installed the app binary and has yet to install a CodePush update
432
+
1. The end-user hasn't installed any CodePush updates yet, and therefore, no metadata is available for any updates, regardless what you specify as the `updateState` parameter.
433
433
1. The end-user installed an update of the binary (e.g. from the store), which cleared away the old CodePush updates, and gave precedence back to the JS binary in the binary.
434
+
1. The `updateState` parameter is set to `UpdateState.RUNNING`, but the app isn't currently running a CodePush update. There may be a pending update, which requires an app restart to become active.
435
+
1. The `updateState` parameter is set to `UpdateState.PENDING`, but the app doesn't have any pending updates.
434
436
435
-
2. A [`LocalPackage`](#localpackage) instance which represents the metadata for the currently running CodePush update.
437
+
2. A [`LocalPackage`](#localpackage) instance which represents the metadata for the currently requested CodePush update (either the running or pending).
436
438
437
439
Example Usage:
438
440
439
441
```javascript
440
-
codePush.getCurrentPackage()
441
-
.then((update) => {
442
-
// If the current app "session" represents the first time
443
-
// this update has run, and it had a description provided
444
-
// with it upon release, let's show it to the end user
445
-
if (update.isFirstRun&&update.description) {
446
-
// Display a "what's new?" modal
442
+
// Check if there is currently a CodePush update running, and if
443
+
// so, register it with the HockeyApp SDK (https://github.com/slowpath/react-native-hockeyapp)
444
+
// so that crash reports will correctly display the JS bundle version the user was running.
// There's a pending update, do we want to force a restart?
447
455
}
448
456
});
449
457
```
@@ -486,7 +494,6 @@ This method provides support for two different (but customizable) "modes" to eas
486
494
487
495
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.
488
496
489
-
490
497
Example Usage:
491
498
492
499
```javascript
@@ -650,7 +657,7 @@ The CodePush API includes the following enums which can be used to customize the
650
657
651
658
##### InstallMode
652
659
653
-
This enum specified when you would like an installed update to actually be applied, and can be passed to either the `sync` or `LocalPackage.install` methods. It includes the following values:
660
+
This enum specifies when you would like an installed update to actually be applied, and can be passed to either the `sync` or `LocalPackage.install` methods. It includes the following values:
654
661
655
662
* __codePush.InstallMode.IMMEDIATE__ *(0)* - Indicates that you want to install the update and restart the app immediately. This value is appropriate for debugging scenarios as well as when displaying an update prompt to the user, since they would expect to see the changes immediately after accepting the installation. Additionally, this mode can be used to enforce mandatory updates, since it removes the potentially undesired latency between the update installation and the next time the end user restarts or resumes the app.
656
663
@@ -672,6 +679,16 @@ This enum is provided to the `syncStatusChangedCallback` function that can be pa
672
679
* __codePush.SyncStatus.SYNC_IN_PROGRESS__ *(7)* - There is an ongoing `sync` operation running which prevents the current call from being executed.
673
680
* __codePush.SyncStatus.UNKNOWN_ERROR__ *(-1)* - The sync operation encountered an unknown error.
674
681
682
+
##### UpdateState
683
+
684
+
This enum specifies the state that an update is currently in, and can be specified when calling the `getUpdateMetadata` method. It includes the following values:
685
+
686
+
* __codePush.UpdateState.RUNNING__ *(0)* - Indicates that an update represents the version of the app that is currently running. This can be useful for identifying attributes about the app, for scenarios such as displaying the release description in a "what's new?" dialog or reporting the latest version to an analytics and/or crash reporting service.
687
+
688
+
* __codePush.UpdateState.PENDING__ *(1)* - Indicates than an update has been installed, but the app hasn't been restarted yet in order to apply it. This can be useful for determining whether there is a pending update, which you may want to force a programmatic restart (via `restartApp`) in order to apply.
689
+
690
+
* __codePush.UpdateState.LATEST__ *(2)* - Indicates than an update represents the latest available release, and can be either currently running or pending.
691
+
675
692
### Objective-C API Reference (iOS)
676
693
677
694
The Objective-C API is made available by importing the `CodePush.h` header into your `AppDelegate.m` file, and consists of a single public class named `CodePush`.
0 commit comments