Skip to content

Instantly share code, notes, and snippets.

@spencercarli
Created October 27, 2016 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencercarli/2541f85684282a3827ec4740db96533e to your computer and use it in GitHub Desktop.
Save spencercarli/2541f85684282a3827ec4740db96533e to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Platform,
TouchableOpacity,
} from 'react-native';
import OneSignal from 'react-native-onesignal';
class App extends Component {
componentDidMount() {
OneSignal.configure({});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to the OneSignal Example!
</Text>
<Text style={styles.instructions}>
Using {Platform.OS}? Cool.
</Text>
{Platform.OS === 'ios' ?
<TouchableOpacity
onPress={() => OneSignal.registerForPushNotifications()}
style={{ padding: 20, backgroundColor: '#3B5998' }}
>
<Text style={{ color: '#fff' }}>Request Push Notification Permission</Text>
</TouchableOpacity>
: null}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment