1

This sharing code isn't working for desktop share but working fine in mobile share. In desktop i'm getting error.

enter image description here

function getBase64Image(img) {

    var canvas = document.createElement("canvas");
    canvas.width = 614;
    canvas.height = 1079;
    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);

    var dataURL = canvas.toDataURL("image/png");
    return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}


function fbShare() {


FBInstant.shareAsync(
    {
        intent: 'SHARE',
        image: getBase64Image(document.getElementById('loveimage1')),
        text: 'What type of lover are you? Find Out. Share. Win.',
        data: {
                myReplayData: '...'
            }
    }).then( function()
    {
    console.log("sharing is done");
    })
    .catch( function(err)
    {
    console.log('failed to share: ' + err.code + " :: " + err.message);
    });
};
Naresh
  • 16,698
  • 6
  • 112
  • 113

0 Answers0