react-native: share api passing base64 string instead of image to WhatsApp - javascript

Hey i am struggling with sharing an base64 image via WhatsApp. In iOS also Android the actual base 64 is been shared instead of the image.
If I use iMessage or Email (iOS) the base64 images is been converted and displayed as expected. In Android using Email for sharing displays just the base64 string. Did anyone else face the same issue?
I am using react-native ~0.55.2
react-native Share API
import React, { Component } from 'react';
import {Image, Text, StyleSheet, View, Share, Button} from 'react-native';
class ShareClass extends Component {
onClick() {
Share.share({
message: REACT_ICON, //for whats app
url: REACT_ICON, // for other applications
title: 'Wow, did you see that?'
}, {
// Android only:
dialogTitle: 'Share BAM goodness',
})
}
render() {
return (
<View style={styles.container}>
<Button
title ="Testing the Share Button"
onPress = {this.onClick}>
</Button>
<Text>Testing the display of base64 image</Text>
<Image source = {{uri:REACT_ICON, width:100, height: 100}} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
const REACT_ICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAd4klEQVR42u1dCZgU1bUuN/KyuDwxL2I0UWM0i9uToMaocUmiRn2+p7i9aNxjVNyIaFAUEZco+tQkLggqPlEU1xh35KGoiDgsM91dVT0DIiKCC4yiw0zPVNV95/y3WKbrVvXt7qqambbv99U3Q9NTdesu557lP/8xjHqrt3qrt3qrt3qrt3qrt3qrt3qrt5RaVvQzMoXdDEsMN2zximF58+nnMsP2PqXPPqLf3zMsdzb9nGiYzlDDFL80zLYBhhAb9Lp3scXG9D570s+LqM+PU/9z9D4f089VdHXR5wW6VtC75Q3TfYTe5ffG3PZte+W7pNIWi6/TIOxPg3UPDdByGhyPLhFxdWJQbXEbDfSRdO1gtIiv9fh7zBSbUL92oesUuh7HpJd+F/7/z+jdJxh5sV+veI9UW4P4Bg3WBTRYlsZgqa42uqbS4A2nRbQ37pd2m9u6GT37V0azuJHeYx69j1P2e+SFS3+bpfucZTz/VVkEk0nk5dxR9O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ojQj4zYJSbBWMS0yld1bagMQIgs/n6kwBT8EUiju1ugwl8BHoWhiiUwa3W1wuY8Z0rjNUAvBW4PXv39hvOypILcuYvSCDuKchfJ6NdGY8SuohLG2fXssDheO/i3gqKOYUILSZjGo8MPsfMlyMj2yVK4lZuN93oih0pdMnLmL+uUoahQdbNRMY7Inzu8LnHOaVcDCGkfyWMlkACXvXis0B89DUqXpnFwSy4fUb29SaO291bWSkTZGZlo12MBs1y/oqJqnSAx5pjbQQGtdnVw84doAMFSmZV1T0Vk3p20rmvw/yMTRiKqgMsl0EtC+um0R2D+uKGE6FnxW0MtogZevyywEVG5MEHsIBrSr0s31T8clrGL4kFE3TgfXhYcBYCKG+Ykin0SzjNO9ubp3JanUbKEwvyDzEVhR9GvMjQRe4tFweulk7q4u1ClpX4rvmUNKec01WczxfsX5KlOrM86w0CQRlhCcQmaLiX5SxxeRKWPA1XszwNBZjak5bdqGPg/fvQrpVYwtWAUq2Lx4hHSJY0Nz+3hnsx5iKwEoBVROEbWSDxCcyJ/SmfdhxG7ifPqnkI5turfSoE/0K5p2lMcrIG5Filmclgy7a01Qrerm+q8ycu6bPtvpKMN2R9M10WfvDjuuFhlN7dsbNd1wbpdRyVvXdYsd5b1gZDqTE58oB+fe6TOEFGJ+h1YssppvApU9R2oUidDb8dJn/iQKOsVZhDlKoZVm7X30HgvKkAhRk/8RAlBfmdYAxsuLSMznKyZdsIDTHwcFspGUvLSBE9bK/rQADvepX+0K09glFX/WGZJa/aBe06QT5EDfedOqRTnHWbOmeB5cQQw1S5IPSLetEJsC05cTf0S6u1WSwnX1xH8OzyLH/NNgN+u1bmJmEuUMGFlm7SkwhVlcb89bCsIIU0yBQphlulhOpARXTu/TkmWxqo1l9BMcy3caObJEQODIFDRITVuEyiyWuBxJH+yR7POQr3qrt3qrt3qrt3qrt3qrt3qrt3rrQ+3/ATxSgu3z5tTfAAAAAElFTkSuQmCC';
export default ShareClass

I am not sure how it will work with inbuilt Share functionality added by react-native. But using react-native-share worked for me.
I have found a working workaround for this problem. Currently, I also use it in one of my applications. You can directly plug and play the below onClick function on a button press.
RNFS.downloadFile, downloads the remote image using URL and save it to a path.
RNFS.readFile, converts the locally saved file data to base64 which is supported directly by Whatsapp and other applications.
import Share from 'react-native-share';
import RNFS from 'react-native-fs';
async onClick(url, id){
const path = `${RNFS.DocumentDirectoryPath}/${id}.jpg`;
await RNFS.downloadFile({ fromUrl: url, toFile: `file://${path}` }).promise
.then((res) => {
return res;
})
.catch((err) => {
return err;
});
RNFS.readFile(`file://${path}`, 'base64').then((res) => {
let shareOptionsUrl = {
title: 'My Application',
message: 'Use my application',
url: `data:image/jpeg;base64,${res}`, // use image/jpeg instead of image/jpg
subject: 'Share information from your application'
};
Share.open(shareOptionsUrl);
})
}
Url is the image remote URL and id is some unique identifier for that image.

Related

React and OpenSeadragon draw polygons on image

I'm writing my web-app with create-react-app and I want to create a viewer to render an image and create multiple editable polygons on it.
OpenSeadragon is perfect for this job, in particular there is a useful plugin OpenseadragonFabricjsOverlay that use fabric.js.
So after I installed the following libraries:
"#types/fabric": "^4.5.12",
"#types/openseadragon": "^3.0.4",
"fabric": "^5.2.4",
"openseadragon": "^3.1.0",
"openseadragon-fabricjs-overlay": "github:altert/OpenseadragonFabricjsOverlay"
and created Viewer component
import React, { useEffect } from 'react';
import OpenSeadragon from 'openseadragon';
// eslint-disable-next-line #typescript-eslint/ban-ts-comment
// #ts-ignore
import 'openseadragon-fabricjs-overlay/openseadragon-fabricjs-overlay';
import { fabric } from 'fabric';
const Viewer = () => {
useEffect(() => {
const viewer = OpenSeadragon({
id: 'seadragon-viewer',
tileSources: {
type: 'image',
url: 'path/to/image/jpg'
}
});
// Initialize overlay
const options = {
scale: 1000
}
const overlay = viewer.fabricjsOverlay(options);
return () => {
viewer.destroy();
};
});
return (
<div id="seadragon-viewer" style={{ height: '100%', width: '100%' }}></div>
);
};
export default Viewer;
I get that error:
[openseadragon-canvas-overlay] requires OpenSeadragon
This occurs because OpenSeaDragon has not yet loaded.
How can I include the openseadragon-fabricjs-overlay.js file after OpenSeadragon?
Do you have advices?
UPDATE:
Follow this issue to fix it
The fabric overlay is assuming that OpenSeadragon will be found on the global window object. You might be able to fix it by adding this between the OSD and plugin imports:
window.OpenSeadragon = OpenSeadragon;

How to generate a QR Code with multiple values like name, email, etc in React Native

I am able to create QR Code with single value by using react-native-qrcode-svg package. But not able to add multiple values like name,email, etc.
I have tried these :
Packages:
npm install react-native-svg --save
react-native link react-native-svg
npm install react-native-qrcode-svg --save
Code for generating QR Code using single value.
import * as React from 'react';
import QRCode from 'react-native-qrcode-svg';
export default class App extends React.Component {
render() {
return (
<QRCode
value="Here I want to add name, email,etc"
/>
);
};
}
I want to generate something like this
You can use rn-qr-generator module to create QRCode Image with a given string.
To generate a QRCode image with an object just do something like this
import RNQRGenerator from 'rn-qr-generator';
RNQRGenerator.generate({
value: JSON.stringify({ email: 'some.email.com', name: 'Name' })
height: 100,
width: 100,
base64: false, // default 'false'
backgroundColor: 'black', // default 'white'
color: 'white', // default 'black'
})
.then(response => {
const { uri, width, height, base64 } = response;
this.setState({ imageUri: uri });
})
.catch(error => console.log('Cannot create QR code', error));
According to the documentation here, https://www.npmjs.com/package/react-native-qrcode-svg, the value can be an array:
String Value of the QR code. Can also accept an array of segments as defined in Manual mode. Ex. [{ data: 'ABCDEFG', mode: 'alphanumeric' }, { data: '0123456', mode: 'numeric' }, { data: [253,254,255], mode: 'byte' }]
Hence the code should be
import * as React from 'react';
import QRCode from 'react-native-qrcode-svg';
export default class App extends React.Component {
render() {
return (
<QRCode
value="[{ name: 'my name'},{ email: 'email#email.com' }]"
/>
);
};
}
I never used react, but shouldn't be something like
value={`"name={name},email={email},phone={phone}"`}
enough to compute the value?
<QRCode
value={`${email},${mdp}`}
/>
if you want to read the data:
data=result.split(",")

No upload button using FilePond ReactJs

Good day,
I am wanting to Use FilePond with Reactjs to facilitate image uploads to a server.What I want is to have the file populate in the Pond like the description shows then for the upload button to appear for the user to upload the file.
Initially from using their demo code I noticed that it would auto-upload files and from reading the documentation I see that I disable that auto upload feature using "instantUpload={false}" in my server. However I have done this and I still don't have an upload button for the user to use. I read the documentation some more and they say I need to specify the server which I have . Is there something that I am missing to show the upload button in my code.
Code below:
import React, { Component } from "react";
/*import agent from "superagent";*/
import classNames from "classnames";
import cookie from 'react-cookies';
// Import React FilePond
import { FilePond, registerPlugin } from "react-filepond";
// Import FilePond styles
import "filepond/dist/filepond.min.css";
// Import the Image EXIF Orientation and Image Preview plugins
// Note: These need to be installed separately
import FilePondPluginImageExifOrientation from "filepond-plugin-image-exif-orientation";
import FilePondPluginImagePreview from "filepond-plugin-image-preview";
import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css";
// Register the plugins
registerPlugin(FilePondPluginImageExifOrientation, FilePondPluginImagePreview);
export default class FotoUpload extends Component {
constructor(props) {
super(props);
this.state = {
// Set initial files, type 'local' means this is a file
// that has already been uploaded to the server (see docs)
files: [
{
source: "index.html",
options: {
type: "local"
}
}
]
};
}
handleInit() {
console.log("FilePond instance has initialised", this.pond);
}
render() {
return (
<div className="App">
{/* Pass FilePond properties as attributes */}
<FilePond
ref={ref => (this.pond = ref)}
allowFilePoster={true}
instantUpload={false}
server=
{
{
url: 'http://mybackend.com:5000/upload/images',
process: {
headers: {
'cookie-token': cookie.load('cookie')
},
}
}
}
name="image"
acceptedFileTypes={['image/*']}
oninit={() => this.handleInit()}
onupdatefiles={fileItems => {
// Set currently active file objects to this.state
this.setState({
files: fileItems.map(fileItem => fileItem.file)
});
}}
/>
</div>
);
}
}
If I allow the instaupload feature the file will upload and success will return , but I will still not receive an Upload button.
Myimage
As you can see there isn't an upload button like shown in the offical documentation.
Similar problem
https://github.com/pqina/vue-filepond/issues/5
FilePond Documentation
https://pqina.nl/filepond/docs/patterns/api/server/
Official repo
https://github.com/pqina/react-filepond

react-native-i18n: undefined is not an object (evaluating 'RNI18n.languages')

So, I want to setup multilanguage support for my app. On the base of react-native. However, when looking at i18n solution it pops up an error:
I followed the installation step on https://github.com/AlexanderZaytsev/react-native-i18n, everything installed and got linked ok, without errors. Tried to setup most basic sample on completely new project. The "App.js" file looks as follows:
import I18n from 'react-native-i18n'
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>{I18n.t('greeting')}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
I18n.fallbacks = true
I18n.translations = {
en: {
greeting: 'Hi!'
},
fr: {
greeting: 'Bonjour!'
}
}
Whenever I try to run it on emulator, the systems pops that error. Driving me nuts at this point. Any known solutions I have missed at this point?
In your project, execute:
$ react-native link
and reboot.
See:
https://github.com/AlexanderZaytsev/react-native-i18n#manual-setup
https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-2

Take screenshot of React app and generate it as PDF

I'd like to generate a PDF from my React App, the easiest way would probably be to take a screenshot of the current state of my app / ideally a div and save it as PDF...I just don't seem to be able to find the best way how to do it.
Any ideas?
For anyone reading this pdfkit can also generate pdfs in the browser...nice!
You'll need to check out pdfkit website and specifically I only got it to work using the browser releases for pdfkit and blob-stream
https://github.com/devongovett/pdfkit/releases
https://github.com/devongovett/blob-stream/releases
My code looked like
import PDFDocument from 'pdfkit'
import BlobStream from 'blob-stream'
import FileSaver from 'file-saver'
let doc = new PDFDocument()
let stream = doc.pipe(BlobStream())
addHeader(doc, 'My Report.....')
doc.moveDown(0.5).fontSize(8)
// render you doc
// then add a stream eventListener to allow download
stream.on('finish', ()=>{
let blob = stream.toBlob('application/pdf')
FileSaver.saveAs(blob, 'myPDF.pdf')
})
doc.end()
How about a combination of:
html2canvas: https://html2canvas.hertzen.com/
and
jsPDF: https://parall.ax/products/jspdf
From the canvas provided by html2canvas, you can convert it to an image with .toDataUrl() and then feed that into jsPDF with the .addImage() method which wants a base64 image.
Using html2canvas and jsPDF created a react components that export the div and its children components as pdf and Image
The react component is defined as following
import React from 'react'
import html2canvas from 'html2canvas'
import { jsPDF } from "jspdf";
class Exporter extends React.Component {
constructor(props) {
super(props)
}
export =(type, name)=>{
html2canvas(document.querySelector(`#capture`)).then(canvas => {
let dataURL = canvas.toDataURL('image/png');
if (type === 'pdf') {
const pdf = new jsPDF({
orientation: "landscape",
unit: "in",
format: [14, 10]
});
pdf.addImage(dataURL, 'PNG', .6, .6);
pdf.save(`${name}.pdf`);
} else if (type === 'png') {
var link = document.createElement('a');
link.download = `${name}.png`;
link.href = dataURL;
link.click();
}
});
}
render() {
return (
<div>
<button onClick={()=>this.export("pdf", "my-content")}></button>
<div id={`capture`} >
Content to export as pdf/png
{this.props.children} //any child Component render here will be exported as pdf/png
</div>
</div>
)
}
}
export default Exporter

Categories