The websocket on my server sends my react-native app an arraybuffer of a PDF and from there I'm trying to figure out how to display the PDF. I feel like rn-fetch-blob would be the answer but I'm not sure what goes where. On the browser, I just did this:
const pdfBlob = new Blob([e.data], {type: "application/pdf"})
const url = URL.createObjectURL(pdfBlob);
pdfViewer.setAttribute("src", url)
But React Native doesn't support making Blobs like that. My next attempt was doing something like this:
fetch(e.data, {
responseType: "arraybuffer"
})
.then(res => res.arrayBuffer())
.then(res => res.blob())
.then(pdfBlob => {
const url = URL.createObjectURL(pdfBlob);
/** ... */
})
.catch(e => console.error(e));
But that didn't work either. I know this guy got it working for images when his response from the server was a blob, but I don't know if it's the same thing.
I'm still super shakey on arraybuffers, blobs, fetching, etc. so any help is much appreciated.