Files
react-native-code-push/Recipes/UpdateOnStart.ios.js
Geoffrey Goh a97407508b updated sync
2015-11-17 18:24:56 -08:00

45 lines
886 B
JavaScript

'use strict';
var pkg = require('./package');
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = React;
var CodePush = require('react-native-code-push');
var UpdateOnStart = React.createClass({
componentDidMount: function() {
CodePush.checkForUpdate().done((update) => {
if (update && update.downloadUrl) {
update.download().done((newPackage) => {
newPackage.install();
});
}
});
},
render: function() {
return (
<View style={styles.container}>
<Text>
Welcome to {pkg.name} {pkg.version}!
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
AppRegistry.registerComponent('UpdateOnStart', () => UpdateOnStart);