/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
TouchableOpacity,
View,
} = React;
var Button = require("react-native-button");
var CodePush = require('react-native-code-push');
var CodePushDemoApp = React.createClass({
getInitialState: function() {
return {};
},
componentDidMount: function() {
this.checkUpdate();
},
checkUpdate: function() {
CodePush.checkForUpdate().done((update) => {
this.setState({ update: update });
});
CodePush.notifyApplicationReady().done();
},
getInitialState: function() {
return { update: false };
},
handlePress: function() {
this.state.update.download().done((localPackage) => {
localPackage.apply().done();
});
},
render: function() {
var updateView;
if (this.state.update) {
updateView = (
Update Available: {'\n'} {this.state.update.scriptVersion} - {this.state.update.description}
);
};
return (
Welcome to Code Push!
{updateView}
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('CodePushDemoApp', () => CodePushDemoApp);