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

Commit e0b3c09

Browse files
author
Will Anderson
committed
Add recipe for automatic update on start
1 parent 38fbf64 commit e0b3c09

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Recipes/UpdateOnStart.ios.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
var pkg = require('./package');
4+
var React = require('react-native');
5+
var {
6+
AppRegistry,
7+
StyleSheet,
8+
Text,
9+
View,
10+
} = React;
11+
12+
var CodePush = require('react-native-code-push');
13+
14+
var UpdateOnStart = React.createClass({
15+
componentDidMount: function() {
16+
CodePush.checkForUpdate().done((update) => {
17+
if (update && update.downloadUrl) {
18+
update.download().done((newPackage) => {
19+
newPackage.apply();
20+
});
21+
}
22+
});
23+
},
24+
render: function() {
25+
return (
26+
<View style={styles.container}>
27+
<Text>
28+
Welcome to {pkg.name} {pkg.version}!
29+
</Text>
30+
</View>
31+
);
32+
}
33+
});
34+
35+
var styles = StyleSheet.create({
36+
container: {
37+
flex: 1,
38+
justifyContent: 'center',
39+
alignItems: 'center',
40+
backgroundColor: '#F5FCFF',
41+
}
42+
});
43+
44+
AppRegistry.registerComponent('UpdateOnStart', () => UpdateOnStart);

0 commit comments

Comments
 (0)