Skip to content

Instantly share code, notes, and snippets.

@axemclion
Created October 28, 2015 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axemclion/62fc009a60efe5d4ebcf to your computer and use it in GitHub Desktop.
Save axemclion/62fc009a60efe5d4ebcf to your computer and use it in GitHub Desktop.
Using HockeyApp SDK with ReactNative Android
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
NativeModules,
TouchableHighlight,
ScrollView,
ToastAndroid,
ListView
} = React;
var cordova = require('react-native-cordova-plugin');
const HOCKEY_TOKEN = '91b18fb9ccb54f28babfa42a0b367710';
var myApp = React.createClass({
componentDidMount: function() {
cordova.hockeyapp.start(function() {
ToastAndroid.show('HockeyApp SDK Initialized', ToastAndroid.LONG);
this.checkForUpdates();
}.bind(this), function() {
ToastAndroid.show('Error initializing Hockeyapp SDK', ToastAndroid.LONG);
}, HOCKEY_TOKEN);
},
checkForUpdates: function() {
cordova.hockeyapp.checkForUpdate(function() {
ToastAndroid.show('Checked for updates', ToastAndroid.LONG);
}, function() {
ToastAndroid.show('Could not check for updates', ToastAndroid.LONG);
})
},
feedback: function() {
cordova.hockeyapp.feedback(function() {}, function() {
ToastAndroid.show('Could not show the UI for leaving feedback', ToastAndroid.LONG);
});
},
forceCrash: function() {
cordova.hockeyapp.forceCrash();
},
render: function() {
return (
<ScrollView>
<Text style={styles.heading}>Hockey App Plugin Demo</Text>
<Text style={styles.heading2}>version 2</Text>
<TouchableHighlight style={styles.button} onPress={()=>this.checkForUpdates()}>
<Text>Check for updates</Text>
</TouchableHighlight>
<TouchableHighlight style={styles.button} onPress={()=>this.feedback()}>
<Text>Leave Feedback</Text>
</TouchableHighlight>
<TouchableHighlight style={styles.button} onPress={()=>this.forceCrash()}>
<Text>Force App Crash</Text>
</TouchableHighlight>
</ScrollView>
)
},
});
AppRegistry.registerComponent('rnapp', () => myApp);
var styles = {
heading: {
fontSize: 20,
margin: 10,
textAlign: 'center'
},
heading2: {
fontSize: 20,
marginTop: 10,
marginBottom: 40,
textAlign: 'center'
},
button: {
borderWidth: 1,
borderColor: '#ccc',
margin: 5,
padding: 5
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment