Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Get Image Data from Screenshot

When creating an iAd, there doesn't seem to be a way to get the image data from a image that the user as created via a screenshot because of the cross domain ruling with canvas elements and images (the image from the screenshots get loaded in with an iad-image://{{project}}/{{random string}} url.


I am trying to send a screenshot of the iAd to Twitter as an attachment, however, I am getting a URL Invalid Error. I believe the only URL protocols that are allowed are http(s): and data, and the screenshot from iAd is a iad-image: protocol.

//screenshot action

this.imageActionDidComplete = function (action) {

var image = iAd.Image.imageForURL(action.url);

var message = new iAd.TwitterMessage({

body: 'Some body',

attachments: [

{type: 'image', url: action.url, name: 'ImageUrl.png'}

]

}, self);

// errors with iAd.URLResourceError.INVALID_URL_ERROR

message.presentWhenReady();

}


Is there a way to get the raw image data without the cross-domain canvas errors?


**edited for formatting**

Posted on Jul 15, 2015 8:02 AM

Reply
1 reply

Jul 16, 2015 8:48 AM in response to xGrill

I found the solution to this just in case anyone else runs into similar issues.


You can not use the screenCapture for pretty much anything besides just displaying the image to the user or saving it to the photo album.


What you have to do is draw everything to an HTML 5 Canvas and use the toDataUrl() to generate a data:base64 URL, which you can then use to upload to Twitter.

Get Image Data from Screenshot

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.