Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 9085a61

Browse files
committed
Adding getCurrentPackage docs back
1 parent d0eb52c commit 9085a61

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ When you require `react-native-code-push`, the module object provides the follow
378378

379379
* [checkForUpdate](#codepushcheckforupdate): Asks the CodePush service whether the configured app deployment has an update available.
380380

381+
* [getCurrentPackage](#codepushgetcurrentpackage): Retrieves the metadata about the currently installed update (e.g. description, installation time, size). *NOTE: As of `v1.10.3-beta` of the CodePush module, this method is deprecated in favor of [`getUpdateMetadata`](#codepushgetupdatemetadata)*.
382+
381383
* [getUpdateMetadata](#codepushgetupdatemetadata): Retrieves the metadata for an installed update (e.g. description, mandatory).
382384

383385
* [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.
@@ -417,6 +419,39 @@ codePush.checkForUpdate()
417419
});
418420
```
419421

422+
#### codePush.getCurrentPackage
423+
424+
*NOTE: This method is considered deprecated as of `v1.10.3-beta` of the CodePush module. If you're running this version (or newer), we would recommend using the [`codePush.getUpdateMetadata`](#codepushgetupdatemetadata) instead, since it has more predictable behavior.*
425+
426+
```javascript
427+
codePush.getCurrentPackage(): Promise<LocalPackage>;
428+
```
429+
430+
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.
431+
432+
This method returns a `Promise` which resolves to one of two possible values:
433+
434+
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:
435+
436+
1. The end-user installed the app binary and has yet to install a CodePush update
437+
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.
438+
439+
2. A [`LocalPackage`](#localpackage) instance which represents the metadata for the currently running CodePush update.
440+
441+
Example Usage:
442+
443+
```javascript
444+
codePush.getCurrentPackage()
445+
.then((update) => {
446+
// If the current app "session" represents the first time
447+
// this update has run, and it had a description provided
448+
// with it upon release, let's show it to the end user
449+
if (update.isFirstRun && update.description) {
450+
// Display a "what's new?" modal
451+
}
452+
});
453+
```
454+
420455
#### codePush.getUpdateMetadata
421456

422457
```javascript

0 commit comments

Comments
 (0)