/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View, TouchableOpacity, processColor, Switch, ScrollView } from 'react-native'; import Instabug from'instabug-reactnative'; const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', }); export default class App extends Component<{}> { constructor(props) { super(props); this.state = { switchValue: false, colorTheme: 'Dark' }; Instabug.startWithToken("APP_TOKEN", Instabug.invocationEvent.shake); Instabug.setReportCategories("Performance","UI","Flow","Other"); Instabug.setPromptOptionsEnabled(true, true, true); Instabug.setLocale(Instabug.locale.english); } render() { return ( Hello {"Instabug's"} awesome user! The purpose of this application is to show you the different options for customizing the SDK and how easy it is to integrate it to your existing app this.showIntroMessage()}> SHOW INTRO MESSAGE this.invoke()}> INVOKE this.sendBugReport()}> SEND BUG REPORT this.sendFeedback()}> SEND FEEDBACK this.startNewConversation()}> START A NEW CONVERSATION this.showUnreadMessagesCount()}> GET UNREAD MESSAGES COUNT {this.invocationEvent()} Set primary color this.setPrimaryColor('#FF0000')}> RED this.setPrimaryColor('#00FF00')}> GREEN this.setPrimaryColor('#0000FF')}> BLUE this.setPrimaryColor('#FFFF00')}> YELLOW Color Theme: {this.state.colorTheme} ); } invocationEvent() { if(Platform.OS === 'ios') { return( Change Invocation Event this.changeInvocationEvent('Shake')}> SHAKE this.changeInvocationEvent('Button')}> FLOATING BUTTON this.changeInvocationEvent('Screenshot')}> SCREENSHOT this.changeInvocationEvent('None')}> NONE ); } return; } toggleSwitch = (value) => { this.setState({switchValue: value}) if(value) { this.setState({colorTheme: 'Light'}); Instabug.setColorTheme(Instabug.colorTheme.light); } else { this.setState({colorTheme: 'Dark'}); Instabug.setColorTheme(Instabug.colorTheme.dark); } } setPrimaryColor(color) { Instabug.setPrimaryColor(processColor(color)); } showIntroMessage() { Instabug.showIntroMessage(); } invoke() { Instabug.invoke(); } sendBugReport() { Instabug.invokeWithInvocationMode(Instabug.invocationMode.newBug); } sendFeedback() { Instabug.invokeWithInvocationMode(Instabug.invocationMode.newFeedback); } changeInvocationEvent(invocationEvent) { if(invocationEvent === 'Shake') Instabug.setInvocationEvent(Instabug.invocationEvent.shake); if(invocationEvent === 'Button') Instabug.setInvocationEvent(Instabug.invocationEvent.floatingButton); if(invocationEvent === 'Screenshot') Instabug.setInvocationEvent(Instabug.invocationEvent.screenshot); if(invocationEvent === 'None') Instabug.setInvocationEvent(Instabug.invocationEvent.none); } startNewConversation() { Instabug.invokeWithInvocationMode(Instabug.invocationMode.newChat); } showUnreadMessagesCount() { Instabug.getUnreadMessagesCount((count) => { alert("Messages: " + count); }); } } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', backgroundColor: '#F5FCFF', }, details: { textAlign: 'center', color: '#333333', margin: 20, marginTop: Platform.OS === 'ios' ? 40 : 20 }, text: { color: '#FFFFFF', fontSize: 12, fontWeight: 'bold' }, button: { marginTop: 10, backgroundColor: "#1D82DC", padding: 10, alignItems: 'center', borderRadius: 5 }, rowView: { flexDirection: 'row', marginTop: 10 }, textColor: { fontSize: 14, fontWeight: 'bold', marginTop: 10, }, buttonColor: { marginTop: 10, backgroundColor: "#1D82DC", padding: 10, alignItems: 'center', borderRadius: 5, marginRight: 5 }, textSwitchStyle: { marginTop: 10, marginRight: 5, fontWeight: 'bold' }, switchView: { flexDirection: 'row', marginTop: 20, }, textInvoke: { color: '#FFFFFF', fontSize: 10, fontWeight: 'bold' }, contentContainer: { padding: 10 } });