Based on the React Native docs for bridging native modules.
Note: This was written prior to the latest Button SDK release, and will require some tweaks to the context
object. See the migration guide for details.
Based on the React Native docs for bridging native modules.
Note: This was written prior to the latest Button SDK release, and will require some tweaks to the context
object. See the migration guide for details.
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
} = React; | |
var Button = React.NativeModules.ButtonManager; | |
var DropinButton = require('./dropinbutton.ios'); | |
Button.configure('YOUR_APP_ID'); | |
var ButtonReactNative = React.createClass({ | |
getButtonContext: function() { | |
return { | |
subject_location: { | |
latitude: 40.7127, | |
longitude: -74.0059 | |
} | |
} | |
}, | |
render: function() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.text}>Welcome to my audience app!</Text> | |
<DropinButton buttonId="YOUR_BUTTON_ID" | |
context={this.getButtonContext()} | |
style={styles.button} /> | |
</View> | |
); | |
} | |
}); | |
var styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF', | |
}, | |
button: { | |
width: 180, | |
height: 40 | |
}, | |
text: { | |
height: 100 | |
} | |
}); | |
AppRegistry.registerComponent('ButtonReactNative', () => ButtonReactNative); |