UNPKG

airbridge-react-native-sdk

Version:

Airbridge SDK for React Native

77 lines (65 loc) 2.12 kB
import React, { Component } from 'react' import { View, } from 'react-native' import { Styles } from '../common/Styles' import { Colors } from '../common/Colors' import CustomButton from '../component/CustomButton' import CustomTextInput from '../component/CustomTextInput' import { Airbridge, AirbridgeCategory, AirbridgeAttribute } from 'airbridge-react-native-sdk'; export default class SkadPage extends Component { constructor(props) { super(props); this.state = { skCategory: '', skAttributes: '' } } post = () => { var outputCategory = this.state.skCategory.trim() var outputAttributes = this.state.skAttributes.trim() outputCategory = outputCategory.length == 0 ? null : outputCategory outputAttributes = outputAttributes.length == 0 ? null : outputAttributes console.log(`outputCategory: ${outputCategory}`) console.log(`outputAttributes: ${outputAttributes}`) if (outputCategory == null || outputAttributes == null) { return } const dValue = parseFloat(outputAttributes) Airbridge.trackEvent( outputCategory, { [AirbridgeAttribute.VALUE]: dValue, } ) } render() { return ( <View style={Styles.container}> <CustomTextInput title={'skCategory'} placeholder={'skCategory'} accessibilityLabel='skCategory' onChangeText={newText => this.setState({ skCategory: newText })} value={this.state.value} /> <View style={{ margin: 4 }} /> <CustomTextInput title={'skAttributes'} placeholder={'skAttributes'} accessibilityLabel='skAttributes' onChangeText={newText => this.setState({ skAttributes: newText })} value={this.state.value} /> <View style={{ margin: 8 }} /> <CustomButton buttonColor={Colors.blue} title={'skPost'} titleColor='white' accessibilityLabel={'skPost'} onPress={() => this.post()} /> </View> ) } }