This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +103
-0
lines changed Expand file tree Collapse file tree 2 files changed +103
-0
lines changed Original file line number Diff line number Diff line change
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
+ var Button = require ( 'react-native-button' ) ;
12
+
13
+ var CodePush = require ( 'react-native-code-push' ) ;
14
+
15
+ var UpdateButton = React . createClass ( {
16
+ getInitialState : function ( ) {
17
+ return { } ;
18
+ } ,
19
+ componentDidMount : function ( ) {
20
+ CodePush . checkForUpdate ( ) . done ( ( update ) => {
21
+ if ( update && ! update . downloadURL ) {
22
+ this . setState ( {
23
+ update : update
24
+ } ) ;
25
+ }
26
+ } ) ;
27
+ } ,
28
+ update : function ( ) {
29
+ this . state . update . download ( ) . done ( ( newPackage ) => {
30
+ newPackage . apply ( ) ;
31
+ } ) ;
32
+ } ,
33
+ render : function ( ) {
34
+ var updateButton = null ;
35
+ if ( this . state . update ) {
36
+ updateButton = < Button onPress = { this . update } > Update</ Button > ;
37
+ }
38
+
39
+ return (
40
+ < View style = { styles . container } >
41
+ < Text >
42
+ Welcome to { pkg . name } { pkg . version } !
43
+ </ Text >
44
+ { updateButton }
45
+ </ View >
46
+ ) ;
47
+ }
48
+ } ) ;
49
+
50
+ var styles = StyleSheet . create ( {
51
+ container : {
52
+ flex : 1 ,
53
+ justifyContent : 'center' ,
54
+ alignItems : 'center' ,
55
+ backgroundColor : '#F5FCFF' ,
56
+ }
57
+ } ) ;
58
+
59
+ AppRegistry . registerComponent ( 'UpdateButton' , ( ) => UpdateButton ) ;
Original file line number Diff line number Diff line change
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 ) ;
You can’t perform that action at this time.
0 commit comments