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

Commit 3d96100

Browse files
committed
Merge pull request #327 from Microsoft/windows-support
Thanks for all the reviews! merging...
2 parents 70cfbcf + 6ddfdd9 commit 3d96100

19 files changed

+1914
-14
lines changed

CodePush.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,9 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
271271
log("User cancelled the update.");
272272
break;
273273
case CodePush.SyncStatus.UPDATE_INSTALLED:
274-
/*
275-
* If the install mode is IMMEDIATE, this will not get returned as the
276-
* app will be restarted to a new Javascript context.
277-
*/
278274
if (resolvedInstallMode == CodePush.InstallMode.ON_NEXT_RESTART) {
279275
log("Update is installed and will be run on the next app restart.");
280-
} else {
276+
} else if (resolvedInstallMode == CodePush.InstallMode.ON_NEXT_RESUME) {
281277
if (syncOptions.minimumBackgroundDuration > 0) {
282278
log(`Update is installed and will be run after the app has been in the background for at least ${syncOptions.minimumBackgroundDuration} seconds.`);
283279
} else {

README.md

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ This plugin provides client-side integration for the [CodePush service](http://c
77
* [Supported Components](#supported-components)
88
* [Getting Started](#getting-started)
99
* [iOS Setup](#ios-setup)
10-
* [Plugin Installation](#plugin-installation-ios)
11-
* [RNPM](#plugin-installation-ios---rnpm)
12-
* [CocoaPods](#plugin-installation-ios---cocoapods)
13-
* ["Manual"](#plugin-installation-ios---manual)
14-
* [Plugin Configuration](#plugin-configuration-ios)
1510
* [Android Setup](#android-setup)
16-
* [Plugin Installation](#plugin-installation-android)
17-
* [RNPM](#plugin-installation-android---rnpm)
18-
* ["Manual"](#plugin-installation-android---manual)
19-
* [Plugin Configuration](#plugin-configuration-android)
11+
* [Windows Setup](#windows-setup)
2012
* [Plugin Usage](#plugin-usage)
2113
* [Releasing Updates](#releasing-updates)
2214
* [API Reference](#api-reference)
@@ -40,6 +32,7 @@ In order to ensure that your end users always have a functioning version of your
4032

4133
- iOS (8+)
4234
- Android (4.1+)
35+
- Windows (UWP)
4336

4437
We try our best to maintain backwards compatability of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the CodePush plugin in order to support the exact version of React Native you are using. The following table outlines which CodePush plugin versions officially support the respective React Native versions:
4538

@@ -292,6 +285,72 @@ public class MainActivity extends ReactActivity {
292285
}
293286
```
294287

288+
## Windows Setup
289+
290+
Once you've acquired the CodePush plugin, you need to integrate it into the Visual Studio project of your React Native app and configure it correctly. To do this, take the following steps:
291+
292+
### Plugin Installation (Windows)
293+
294+
1. Open the Visual Studio solution located at `windows\<AppName>\<AppName>.sln` within your app
295+
296+
2. Right-click the solution node in the `Solution Explorer` window and select the `Add -> Existing Project...` menu item
297+
298+
![Add Project](https://cloud.githubusercontent.com/assets/116461/14467164/ddf6312e-008e-11e6-8a10-44a8b44b5dfc.PNG)
299+
300+
3. Browse to the `node_modules\react-native-code-push\windows` directory, select the `CodePush.csproj` file and click `OK`
301+
302+
4. Back in the `Solution Explorer`, right-click the project node that is named after your app, and select the `Add -> Reference...` menu item
303+
304+
![Add Reference](https://cloud.githubusercontent.com/assets/116461/14467154/d833bc98-008e-11e6-8e95-09864b1f05ef.PNG)
305+
306+
5. Select the `Projects` tab on the left hand side, check the `CodePush` item and then click `OK`
307+
308+
![Add Reference Dialog](https://cloud.githubusercontent.com/assets/116461/14467147/cb805b6e-008e-11e6-964f-f856c59b65af.PNG)
309+
310+
### Plugin Configuration (Windows)
311+
312+
After installing the plugin, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, update the `AppReactPage.cs` file to use CodePush via the following changes:
313+
314+
```c#
315+
...
316+
// 1. Import the CodePush namespace
317+
using CodePush.ReactNative;
318+
...
319+
class AppReactPage : ReactPage
320+
{
321+
// 2. Declare a private instance variable for the CodePushModule instance.
322+
private CodePushReactPackage codePushReactPackage;
323+
324+
// 3. Update the JavaScriptBundleFile property to initalize the CodePush runtime,
325+
// specifying the right deployment key, then use it to return the bundle URL from
326+
// CodePush instead of statically from the binary. If you don't already have your
327+
// deployment key, you can run "code-push deployment ls <appName> -k" to retrieve it.
328+
public override string JavaScriptBundleFile
329+
{
330+
get
331+
{
332+
codePushReactPackage = new CodePushReactPackage("deployment-key-here", this);
333+
return codePushReactPackage.GetJavaScriptBundleFile();
334+
}
335+
}
336+
337+
// 4. Add the codePushReactPackage instance to the list of existing packages.
338+
public override List<IReactPackage> Packages
339+
{
340+
get
341+
{
342+
return new List<IReactPackage>
343+
{
344+
new MainReactPackage(),
345+
...
346+
codePushReactPackage
347+
};
348+
}
349+
}
350+
...
351+
}
352+
```
353+
295354
## Plugin Usage
296355

297356
With the CodePush plugin downloaded and linked, and your app asking CodePush where to get the right JS bundle from, the only thing left is to add the necessary code to your app to control the following policies:

windows/.gitignore

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
[Ll]og/
24+
25+
# Visual Studio 2015 cache/options directory
26+
.vs/
27+
# Uncomment if you have tasks that create the project's static files in wwwroot
28+
#wwwroot/
29+
30+
# MSTest test Results
31+
[Tt]est[Rr]esult*/
32+
[Bb]uild[Ll]og.*
33+
34+
# NUNIT
35+
*.VisualState.xml
36+
TestResult.xml
37+
38+
# Build Results of an ATL Project
39+
[Dd]ebugPS/
40+
[Rr]eleasePS/
41+
dlldata.c
42+
43+
# DNX
44+
project.lock.json
45+
artifacts/
46+
47+
*_i.c
48+
*_p.c
49+
*_i.h
50+
*.ilk
51+
*.meta
52+
*.obj
53+
*.pch
54+
*.pdb
55+
*.pgc
56+
*.pgd
57+
*.rsp
58+
*.sbr
59+
*.tlb
60+
*.tli
61+
*.tlh
62+
*.tmp
63+
*.tmp_proj
64+
*.log
65+
*.vspscc
66+
*.vssscc
67+
.builds
68+
*.pidb
69+
*.svclog
70+
*.scc
71+
72+
# Chutzpah Test files
73+
_Chutzpah*
74+
75+
# Visual C++ cache files
76+
ipch/
77+
*.aps
78+
*.ncb
79+
*.opendb
80+
*.opensdf
81+
*.sdf
82+
*.cachefile
83+
*.VC.db
84+
*.VC.VC.opendb
85+
86+
# Visual Studio profiler
87+
*.psess
88+
*.vsp
89+
*.vspx
90+
*.sap
91+
92+
# TFS 2012 Local Workspace
93+
$tf/
94+
95+
# Guidance Automation Toolkit
96+
*.gpState
97+
98+
# ReSharper is a .NET coding add-in
99+
_ReSharper*/
100+
*.[Rr]e[Ss]harper
101+
*.DotSettings.user
102+
103+
# JustCode is a .NET coding add-in
104+
.JustCode
105+
106+
# TeamCity is a build add-in
107+
_TeamCity*
108+
109+
# DotCover is a Code Coverage Tool
110+
*.dotCover
111+
112+
# NCrunch
113+
_NCrunch_*
114+
.*crunch*.local.xml
115+
nCrunchTemp_*
116+
117+
# MightyMoose
118+
*.mm.*
119+
AutoTest.Net/
120+
121+
# Web workbench (sass)
122+
.sass-cache/
123+
124+
# Installshield output folder
125+
[Ee]xpress/
126+
127+
# DocProject is a documentation generator add-in
128+
DocProject/buildhelp/
129+
DocProject/Help/*.HxT
130+
DocProject/Help/*.HxC
131+
DocProject/Help/*.hhc
132+
DocProject/Help/*.hhk
133+
DocProject/Help/*.hhp
134+
DocProject/Help/Html2
135+
DocProject/Help/html
136+
137+
# Click-Once directory
138+
publish/
139+
140+
# Publish Web Output
141+
*.[Pp]ublish.xml
142+
*.azurePubxml
143+
# TODO: Comment the next line if you want to checkin your web deploy settings
144+
# but database connection strings (with potential passwords) will be unencrypted
145+
*.pubxml
146+
*.publishproj
147+
148+
# Microsoft Azure Web App publish settings. Comment the next line if you want to
149+
# checkin your Azure Web App publish settings, but sensitive information contained
150+
# in these scripts will be unencrypted
151+
PublishScripts/
152+
153+
# NuGet Packages
154+
*.nupkg
155+
# The packages folder can be ignored because of Package Restore
156+
**/packages/*
157+
# except build/, which is used as an MSBuild target.
158+
!**/packages/build/
159+
# Uncomment if necessary however generally it will be regenerated when needed
160+
#!**/packages/repositories.config
161+
# NuGet v3's project.json files produces more ignoreable files
162+
*.nuget.props
163+
*.nuget.targets
164+
165+
# Microsoft Azure Build Output
166+
csx/
167+
*.build.csdef
168+
169+
# Microsoft Azure Emulator
170+
ecf/
171+
rcf/
172+
173+
# Windows Store app package directories and files
174+
AppPackages/
175+
BundleArtifacts/
176+
Package.StoreAssociation.xml
177+
_pkginfo.txt
178+
179+
# Visual Studio cache files
180+
# files ending in .cache can be ignored
181+
*.[Cc]ache
182+
# but keep track of directories ending in .cache
183+
!*.[Cc]ache/
184+
185+
# Others
186+
ClientBin/
187+
~$*
188+
*~
189+
*.dbmdl
190+
*.dbproj.schemaview
191+
*.pfx
192+
*.publishsettings
193+
node_modules/
194+
orleans.codegen.cs
195+
196+
# Since there are multiple workflows, uncomment next line to ignore bower_components
197+
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198+
#bower_components/
199+
200+
# RIA/Silverlight projects
201+
Generated_Code/
202+
203+
# Backup & report files from converting an old project file
204+
# to a newer Visual Studio version. Backup files are not needed,
205+
# because we have git ;-)
206+
_UpgradeReport_Files/
207+
Backup*/
208+
UpgradeLog*.XML
209+
UpgradeLog*.htm
210+
211+
# SQL Server files
212+
*.mdf
213+
*.ldf
214+
215+
# Business Intelligence projects
216+
*.rdl.data
217+
*.bim.layout
218+
*.bim_*.settings
219+
220+
# Microsoft Fakes
221+
FakesAssemblies/
222+
223+
# GhostDoc plugin setting file
224+
*.GhostDoc.xml
225+
226+
# Node.js Tools for Visual Studio
227+
.ntvs_analysis.dat
228+
229+
# Visual Studio 6 build log
230+
*.plg
231+
232+
# Visual Studio 6 workspace options file
233+
*.opt
234+
235+
# Visual Studio LightSwitch build output
236+
**/*.HTMLClient/GeneratedArtifacts
237+
**/*.DesktopClient/GeneratedArtifacts
238+
**/*.DesktopClient/ModelManifest.xml
239+
**/*.Server/GeneratedArtifacts
240+
**/*.Server/ModelManifest.xml
241+
_Pvt_Extensions
242+
243+
# Paket dependency manager
244+
.paket/paket.exe
245+
paket-files/
246+
247+
# FAKE - F# Make
248+
.fake/
249+
250+
# JetBrains Rider
251+
.idea/
252+
*.sln.iml

0 commit comments

Comments
 (0)