diff --git a/Examples/CodePushDemoApp/demo.js b/Examples/CodePushDemoApp/demo.js
index 53e9b91..11619cc 100644
--- a/Examples/CodePushDemoApp/demo.js
+++ b/Examples/CodePushDemoApp/demo.js
@@ -11,6 +11,11 @@ import {
import CodePush from "react-native-code-push";
+/**
+ * Configured with a MANUAL check frequency for easy testing. For production apps, it is recommended to configure a
+ * different check frequency, such as ON_APP_START, for a 'hands-off' approach where CodePush.sync() does not
+ * need to be explicitly called. All options of CodePush.sync() are also available in this decorator.
+ */
@CodePush({ checkFrequency: CodePush.CheckFrequency.MANUAL })
class CodePushDemoApp extends Component {
constructor() {
@@ -39,7 +44,7 @@ class CodePushDemoApp extends Component {
this.setState({ syncMessage: "Update cancelled by user.", progress: false });
break;
case CodePush.SyncStatus.UPDATE_INSTALLED:
- this.setState({ syncMessage: "Update installed.", progress: false });
+ this.setState({ syncMessage: "Update installed and will be applied on restart.", progress: false });
break;
case CodePush.SyncStatus.UNKNOWN_ERROR:
this.setState({ syncMessage: "An unknown error occurred.", progress: false });
@@ -59,12 +64,28 @@ class CodePushDemoApp extends Component {
this.setState({ restartAllowed: !this.state.restartAllowed });
}
+ getUpdateMetadata() {
+ CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING)
+ .then((metadata: LocalPackage) => {
+ this.setState({ syncMessage: metadata ? JSON.stringify(metadata) : "Running binary version", progress: false });
+ }, (error: any) => {
+ this.setState({ syncMessage: "Error: " + error, progress: false });
+ });
+ }
+
+ /** Update is downloaded silently, and applied on restart (recommended) */
sync() {
CodePush.sync(
- {
- installMode: CodePush.InstallMode.IMMEDIATE,
- updateDialog: true
- },
+ {},
+ this.codePushStatusDidChange.bind(this),
+ this.codePushDownloadDidProgress.bind(this)
+ );
+ }
+
+ /** Update pops a confirmation dialog, and then immediately reboots the app */
+ syncImmediate() {
+ CodePush.sync(
+ { installMode: CodePush.InstallMode.IMMEDIATE, updateDialog: true },
this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this)
);
@@ -85,14 +106,20 @@ class CodePushDemoApp extends Component {
Welcome to CodePush!
- Start Sync!
+ Press for silent sync
+
+
+ Press for dialog-driven sync
- {this.state.syncMessage || ""}
{progressView}
Restart { this.state.restartAllowed ? "allowed" : "forbidden"}
+
+ Press for Update Metadata
+
+ {this.state.syncMessage || ""}
);
}
@@ -106,11 +133,12 @@ const styles = StyleSheet.create({
paddingTop: 50
},
image: {
- marginTop: 50,
+ margin: 30,
width: Dimensions.get("window").width - 100,
height: 365 * (Dimensions.get("window").width - 100) / 651,
},
messages: {
+ marginTop: 30,
textAlign: "center",
},
restartToggleButton: {
@@ -124,7 +152,7 @@ const styles = StyleSheet.create({
welcome: {
fontSize: 20,
textAlign: "center",
- margin: 10
+ margin: 20
},
});