#any other information other than it not

1 messages · Page 1 of 1 (latest)

timber totem
#

I'll make a mini thread here

#
    // Function to download and share the image
    const ShareImage = async () => {
        if (navigator.share) {

            let dataUrl: string = "";
            let filesArray: File[];

            for (let i = 0; i < 4; i++) {
                dataUrl = await htmlToImage.toPng(domEl.current!, { pixelRatio: 1.5 });
            }

            const response = await fetch(dataUrl);
            const blob = await response.blob();
            filesArray = [new File([blob!], 'allstarlineup.png', { type: blob!.type, lastModified: new Date().getTime() })];

            const data = { files: filesArray, text: "Check Out My Image" };

            await navigator.share(data);
            // alert("Shared successfully")
        }
    }
#

I currently have a web app deployed through Vercel using HTTPS protocol

#

And this is the function to share an image

#

For some reason, it doesn't seem to work on mobile, even when I don't share the file array and just regular text, nothing seems to work

reef haven
timber totem
#

Yes

reef haven
#

anyways base on my reading just now if your browser is old that it do not support web share api it wont work . if it is you need to call permission to user to do actual share .

timber totem
#

Here's the thing

#

I put an alert() right after if (navigator.share) {} and the alert was triggered

#

But the modal to share the image does not appear

reef haven
#

if you remove alert it works ?

timber totem
#

No

#

It only works on desktop

#

I'm using safari on my mobile phone

#

But I know that navigator.share is supported on the browser because the alert pops up

#

The only thing that doesn't is the ability to share the picutre

reef haven
#

safari thus allow it not unless you have bellow the supported

timber totem
#

Hmm, if this is the case I'm still not sure why my code isn't working

#

Because I'm using data.files already

#

Hmm this is weird :/