ionic capacitor share plugin not sharing image with whatsapp

Discussão em 'Angular' iniciado por Mansour Alnasser, Junho 16, 2025.

  1. I have created this function that shares image very well on many applications, but when it comes to WhatsApp or Instagram it not sharing the image.

    I'm using Ionic v5 with capacitor v3



    async shareImage() {
    let receiptName = 'Receipt N:123.png';
    const div = this.screenshotElement.nativeElement;
    const divHeight = div.clientHeight;
    const divWidth = div.clientWidth;
    const options = { background: '#ffffff', width: divWidth, height: divHeight };

    await Filesystem.requestPermissions();

    let base64Data = await domtoimage.toPng(div, options);

    // device shareing
    await Filesystem.writeFile({
    path: receiptName,
    data: base64Data,
    directory: Directory.Cache
    });


    let fileResult = await Filesystem.getUri({
    directory: Directory.Cache,
    path: receiptName
    });

    let imageLink = Capacitor.convertFileSrc(fileResult.uri);

    Share.share({
    title: receiptName,
    text: receiptName,
    url: fileResult.uri,
    })
    .then(() => console.log('Successful share'))
    .catch((error) => console.log('Error sharing ::: ', error));

    }




    import

    import domtoimage from 'dom-to-image';
    import { Share } from '@capacitor/share';
    import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
    import { Capacitor } from '@capacitor/core';
    import { Camera, CameraResultType } from '@capacitor/camera';


    package

    "@capacitor/android": "^3.1.1",
    "@capacitor/app": "^1.0.2",
    "@capacitor/camera": "^1.0.3",
    "@capacitor/cli": "^3.1.1",
    "@capacitor/core": "^3.1.1",
    "@capacitor/filesystem": "^1.0.2",
    "@capacitor/haptics": "^1.0.2",
    "@capacitor/ios": "^3.1.1",
    "@capacitor/keyboard": "^1.0.2",
    "@capacitor/push-notifications": "^1.0.3",
    "@capacitor/share": "^1.0.3",
    "@capacitor/status-bar": "^1.0.2",

    Continue reading...

Compartilhe esta Página