Tengo por ejemplo un QRCode SMS con el valor:
SMSTO:99999999:Hola mundo
Y quiero generar una imagen de código QR para poder compartirla con react-native-share. ¿Cómo podría hacer eso?
Pasos: instale react-native-qrcode-image
npm install git+https://github.com/Kishanjvaghela/react-native-qrcode-image.git --saveInstalar reaccionar-nativo-compartir
npm install react-native-share --saveVincularlo con la aplicación
react-native link react-native-shareUse QRCode en su componente
import QRCode from 'react-native-qrcode-image'; import Share from 'react-native-share'; class Dashboard extends React.Component { static navigationOptions = { title: Strings.dashboardTitle }; constructor(props) { super(props); this.qrCode = ''; } openShareScreen() { if (this.qrCode) { const shareOptions = { type: 'image/jpg', title: '', url: this.qrCode }; Share.open(shareOptions) .then(res => console.log(res)) .catch(err => console.error(err)); } } render() { const { type, address } = this.state; return ( <TouchableHighlight onPress={this.openShareScreen}> <View> <QRCode getBase64={base64 => { this.qrCode = base64; }} value={address} size={150} bgColor="#FFFFFF" fgColor="#000000" /> </View> </TouchableHighlight> ); } } export default Dashboard;