-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
746 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,100 @@ | ||
import React, { Component } from 'react'; | ||
import { | ||
Text, | ||
View, | ||
} from 'react-native'; | ||
import React, { Component } from "react"; | ||
import { StyleSheet, Text, View, TouchableOpacity } from "react-native"; | ||
import CodePush from "react-native-code-push"; | ||
|
||
class App extends Component { | ||
constructor() { | ||
super(); | ||
this.state = {}; | ||
} | ||
|
||
componentDidMount() { | ||
CodePush.notifyAppReady(); | ||
} | ||
|
||
codePushStatusDidChange(syncStatus) { | ||
switch (syncStatus) { | ||
case CodePush.SyncStatus.CHECKING_FOR_UPDATE: | ||
this.setState({ syncMessage: "Checking for update." }); | ||
break; | ||
case CodePush.SyncStatus.DOWNLOADING_PACKAGE: | ||
this.setState({ syncMessage: "Downloading package." }); | ||
break; | ||
case CodePush.SyncStatus.AWAITING_USER_ACTION: | ||
this.setState({ syncMessage: "Awaiting user action." }); | ||
break; | ||
case CodePush.SyncStatus.INSTALLING_UPDATE: | ||
this.setState({ syncMessage: "Installing update." }); | ||
break; | ||
case CodePush.SyncStatus.UP_TO_DATE: | ||
this.setState({ syncMessage: "App up to date.", progress: false }); | ||
break; | ||
case CodePush.SyncStatus.UPDATE_IGNORED: | ||
this.setState({ syncMessage: "Update cancelled by user.", progress: false }); | ||
break; | ||
case CodePush.SyncStatus.UPDATE_INSTALLED: | ||
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 }); | ||
break; | ||
} | ||
if (this.state.syncMessage) { | ||
console.log(`[CodePush] ${this.state.syncMessage}`); | ||
} | ||
} | ||
|
||
syncImmediate() { | ||
CodePush.sync( | ||
{ installMode: CodePush.InstallMode.IMMEDIATE, updateDialog: true }, | ||
this.codePushStatusDidChange.bind(this), | ||
); | ||
} | ||
|
||
render() { | ||
return ( | ||
<View style={{ padding: 20 }}> | ||
<Text>Version 1</Text> | ||
<View style={styles.container}> | ||
<Text style={styles.welcome}> | ||
Welcome to React Native!{'\n'} | ||
<Text style={{ | ||
color: 'red' | ||
}}> | ||
Update 2 | ||
</Text> | ||
</Text> | ||
<TouchableOpacity onPress={this.syncImmediate.bind(this)}> | ||
<Text>Check for updates</Text> | ||
</TouchableOpacity> | ||
<Text style={styles.messages}>{this.state.syncMessage || ""}</Text> | ||
</View> | ||
); | ||
} | ||
|
||
} | ||
|
||
export default App; | ||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: "center", | ||
alignItems: "center", | ||
backgroundColor: "#FFF" | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: "center", | ||
margin: 10, | ||
color: 'black', | ||
fontWeight: 'bold', | ||
}, | ||
instructions: { | ||
textAlign: "center", | ||
color: "#333333", | ||
marginBottom: 5 | ||
}, | ||
messages: { | ||
marginTop: 30, | ||
textAlign: "center", | ||
color: "green", | ||
}, | ||
}); | ||
|
||
export default CodePush()(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<resources> | ||
<string moduleConfig="true" name="reactNativeCodePush_androidDeploymentKey">v8mJNhylc59dLMys2GuqOvMY91Jmh0AKpS1UZ</string> | ||
<string name="app_name">AwesomeProject</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
rootProject.name = 'AwesomeProject' | ||
include ':react-native-code-push' | ||
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') | ||
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) | ||
include ':app' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>AwesomeProject</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>NSAppTransportSecurity</key> | ||
<dict> | ||
<key>NSAllowsArbitraryLoads</key> | ||
<true/> | ||
<key>NSExceptionDomains</key> | ||
<dict> | ||
<key>localhost</key> | ||
<dict> | ||
<key>NSExceptionAllowsInsecureHTTPLoads</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
<key>NSLocationWhenInUseUsageDescription</key> | ||
<string></string> | ||
<key>UILaunchStoryboardName</key> | ||
<string>LaunchScreen</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UIViewControllerBasedStatusBarAppearance</key> | ||
<false/> | ||
</dict> | ||
</plist> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>AwesomeProject</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>NSAppTransportSecurity</key> | ||
<dict> | ||
<key>NSAllowsArbitraryLoads</key> | ||
<true/> | ||
<key>NSExceptionDomains</key> | ||
<dict> | ||
<key>localhost</key> | ||
<dict> | ||
<key>NSExceptionAllowsInsecureHTTPLoads</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
<key>NSLocationWhenInUseUsageDescription</key> | ||
<string/> | ||
<key>UILaunchStoryboardName</key> | ||
<string>LaunchScreen</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UIViewControllerBasedStatusBarAppearance</key> | ||
<false/> | ||
<key>CodePushDeploymentKey</key> | ||
<string>deployment-key-here</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.