Hi, I am looking to share image as well as url at the same time, but it seems that this library only support one url at a time, is there a way to achieve this thing.
3 thoughts on “is there a way to share image as well as url from this library”
Comments are closed.
Hi, I am looking to share image as well as url at the same time, but it seems that this library only support one url at a time, is there a way to achieve this thing.
1 thought on “is there a way to share image as well as url from this library”
-
I came up with this workaround.
First parse the library url into assets urlconst parseUri = (uri) => { const id = uri.split('photos://')[1].split('/L0/001')[0]; return `assets-library://asset/asset.JPG?id=${id}&ext=JPG` }
And then use RNFetchBlob from react-native-fetch-blob to read from assets url and convert as base64 string
As we got the base64 string we can share it : >
RNFetchBlob.fs .readFile( parseUri(libraryUrl), "base64" ) .then(base64data => { let base64Image = `data:image/jpeg;base64,${base64data}`; Share.open( { url: base64Image } ) .then(() => console.log("He shared!!")) .catch(() => console.log("He didn't share :(")); });
Comments are closed.
I came up with this workaround.
First parse the library url into assets url
And then use RNFetchBlob from react-native-fetch-blob to read from assets url and convert as base64 string
As we got the base64 string we can share it : >
Hey, thanks for the support after more testing I found the problem only happens on iOS, on android you are able to (more or less) easily share and image and a message, but on iOS you cannot place both of them, here is the final code I ended up:
I put the comment snippet a few comments up there ^, did not produce a repository, it should be a matter of copying and pasting