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.
React Native module for deploying script updates using the CodePush service.
5
+
6
+
Installation
7
+
---
8
+
9
+
```
10
+
npm install --save react-native-code-push
11
+
```
12
+
13
+
After installing the React Native CodePush plugin, open your project in Xcode. Open the `react-native-code-push` in Finder, and drag the `CodePush.xcodeproj` into the Libraries folder of Xcode.
14
+
15
+

16
+
17
+
18
+
In Xcode, click on your project, and select the "Build Phases" tab of your project configuration. Drag libCodePush.a from `Libraries/CodePush.xcodeproj/Products` into the "Link Binary With Libraries" secton of your project's "Build Phases" configuration.
19
+
20
+

21
+
22
+
Under the "Build Settings" tab of your project configuration, find the "Header Search Paths" section and edit the value.
23
+
Add a new value, `$(SRCROOT)/../node_modules/react-native-code-push` and select "recursive" in the dropdown.
This change allows CodePush to load the updated app location after an update has been applied.
48
+
Before any updates are installed, CodePush will load your app from the bundled "main.jsbundle" file.
49
+
After updates are installed, CodePush will load your app from the writable user directory, where the update has been downloaded.
50
+
51
+
Methods
52
+
---
53
+
54
+
*[checkForUpdate](#codepushcheckforupdate): Checks the service for updates
55
+
*[notifyApplicationReady](#codepushnotifyapplicationready): Notifies the plugin that the update operation succeeded.
56
+
*[getCurrentPackage](#codepushgetcurrentpackage): Gets information about the currently applied package.
57
+
58
+
Objects
59
+
---
60
+
61
+
*[LocalPackage](#localpackage): Contains information about a locally installed package.
62
+
*[RemotePackage](#remotepackage): Contains information about an updated package available for download.
63
+
64
+
Getting Started:
65
+
---
66
+
67
+
* Add the plugin to your app
68
+
* Open your app's `Info.plist` and add a "CodePushDeploymentKey" entry with your app's deployment key
69
+
* To publish an update for your app, run `react-native bundle`, and then publish `iOS/main.jsbundle` using the CodePush CLI.
5
70
6
71
Running the Example
7
72
---
8
73
9
-
* Make sure you have https://github.com/Microsoft/hybrid-mobile-deploy cloned beside the react-native project in a folder called `website`. This is hacky, and will be cleaned up as soon as React Native's packager supports symlinks.
10
-
* Start the CodePush server with `gulp serve`, after installing the prerequisites described in the [project readme](https://github.com/Microsoft/hybrid-mobile-deploy/blob/master/README.md)
74
+
* Clone this repository
11
75
* From the root of this project, run `npm install`
12
76
*`cd` into `Examples/CodePushDemoApp`
13
77
* From this demo app folder, run `npm install`
14
-
* Open `Info.plist` and fill in the values for CodePushDeploymentKey and CodePushServerUrl
78
+
* Open `Info.plist` and fill in the value for CodePushDeploymentKey
15
79
* Run `npm start` to launch the packager
16
80
* Open `CodePushDemoApp.xcodeproj` in Xcode
17
81
* Launch the project
@@ -22,4 +86,68 @@ Running Tests
22
86
* Open `CodePushDemoApp.xcodeproj` in Xcode
23
87
* Navigate to the test explorer (small grey diamond near top left)
24
88
* Click on the 'play' button next to CodePushDemoAppTests
25
-
* After the tests are completed, green ticks should appear next to the test cases to indicate success
89
+
* After the tests are completed, green ticks should appear next to the test cases to indicate success
90
+
91
+
92
+
## LocalPackage
93
+
Contains details about an update package that has been downloaded locally or already applied (currently installed package).
94
+
### Properties
95
+
-__deploymentKey__: Deployment key of the package. (String)
96
+
-__description__: Package description. (String)
97
+
-__label__: Package label. (String)
98
+
-__appVersion__: The native version of the application this package update is intended for. (String)
99
+
-__isMandatory__: Flag indicating if the update is mandatory. (Boolean)
100
+
-__packageHash__: The hash value of the package. (String)
101
+
-__packageSize__: The size of the package, in bytes. (Number)
102
+
103
+
### Methods
104
+
-__apply(rollbackTimeout): Promise__: Applies this package to the application. The application will be reloaded with this package and on every application launch this package will be loaded.
105
+
If the rollbackTimeout parameter is provided, the application will wait for a codePush.notifyApplicationReady() for the given number of milliseconds.
106
+
If codePush.notifyApplicationReady() is called before the time period specified by rollbackTimeout, the apply operation is considered a success.
107
+
Otherwise, the apply operation will be marked as failed, and the application is reverted to its previous version.
108
+
109
+
## RemotePackage
110
+
Contains details about an update package that is available for download.
111
+
### Properties
112
+
-__deploymentKey__: Deployment key of the package. (String)
113
+
-__description__: Package description. (String)
114
+
-__label__: Package label. (String)
115
+
-__appVersion__: The native version of the application this package update is intended for. (String)
116
+
-__isMandatory__: Flag indicating if the update is mandatory. (Boolean)
117
+
-__packageHash__: The hash value of the package. (String)
118
+
-__packageSize__: The size of the package, in bytes. (Number)
119
+
-__downloadUrl__: The URL at which the package is available for download. (String)
120
+
121
+
### Methods
122
+
-__download(): Promise<LocalPackage>__: Downloads the package update from the CodePush service. Returns a Promise that resolves with the LocalPackage.
123
+
124
+
## codePush.checkForUpdate
125
+
Queries the CodePush server for updates.
126
+
```javascript
127
+
codePush.checkForUpdate():Promise<RemotePackage>;
128
+
```
129
+
130
+
`checkForUpdate` returns a Promise that resolves when the server responds with an update.
0 commit comments