I have a webview
that opens from a messenger bot
.
From the webview
I want to send image data to the conversation (no URL - data coming from the canvas).
I tried to use Messenger SDK
beginShareFlow with file data attachment:
function uploadImage(data) {
let message = {
"attachment": {
"type": "image",
"payload": {
"is_reusable": true
},
"filedata": data
}
};
MessengerExtensions.beginShareFlow(function (share_response) {
// User dismissed without error
if (share_response.is_sent) {
// The user actually did share.
//close the webview
MessengerExtensions.requestCloseBrowser(function success() {
// webview closed
}, function error(err) {
console.log(err);
});
}
},
function (errorCode, errorMessage) {
// An error occurred in the process
console.log(errorMessage);
},
message, "current_thread");
}
But I get an error:
Messenger Extensions unexpected error.
Would appreciate help =]
EDIT:
I found out that filedata
is used to transfer a file location (which I do not have).
So I tried other solutions:
- I created from my cavas
blob
, and tried to pass it infiledata
- did not work - I created a
blob
file (by adding name and date) and tried to move the location - did not work - I created a url from
blob
and tried to move it as a url (not as filedata) - and got an error:
Invalid image URL provided in message content
When I go to the blob url from the browser I see the image =[
filedata
parameter. – Hardenberg