finscn / Ejecta

A Fast, Open Source JavaScript, Canvas & Audio Implementation for iOS
42 stars 6 forks source link

social share and share a png ? #22

Open matrixreal opened 9 years ago

matrixreal commented 9 years ago

@finscn hi i see that in social.m and social.h the image call is implemented but how can we call the social share with image ? i use

var social = new ejecta.social(); var message = "hello";

and the call is openshare.social(message);

how to add the image to the call ?

matrixreal commented 9 years ago

@finscn any suggestion ? because it's already implemented on your code see social.m thanks for feedback

finscn commented 9 years ago

In china , I can't visit twitter and facebook , I can't test the feature...

matrixreal commented 9 years ago

very sad news i'm searching about this since 3 months ok can you just give me a suggestion and i will test it ?

finscn commented 9 years ago

try:social.showPostDialog("twitter", "message", "url" ,"imgSrc", callback)

finscn commented 9 years ago

try: social.showPostDialog("twitter", "message", "url" ,"imgSrc", callback)

matrixreal commented 9 years ago

ok i wil try it now and the image ? i put it in app folder and name it to "image.png" right ? [request addMultipartData:imageData withName:dataName type:@"image/png" filename:@"image.png"];

finscn commented 9 years ago

your file's name could be anything. but must in app folder (or it's sub folder)

finscn commented 9 years ago

I update my fork . Now you could use "${Documnets} ${tmp} ....

matrixreal commented 9 years ago

ok but not work when i use social.showPostDialog("twitter", "message", "url" ,"imgSrc", callback); got black screen when i use social.showPostDialog("twitter", "message", "url" ,"imgSrc", callback); got js error line 1 colum 30

matrixreal commented 9 years ago

but i will downloadthe latest fork and try again

matrixreal commented 9 years ago

same error

matrixreal commented 9 years ago

main file (index.js) should have this declaration right ? var social = new ejecta.social(); var message = "hello"; ?

finscn commented 9 years ago

please post your code .

I found that you don't like post your code when you ask some questions.

Your code is always a secret ?

matrixreal commented 9 years ago

no it's not secret this is what i use in the main file (index.js) i put var social = new ejecta.social(); var message = "hello"; and when i call the facebook or twitter message and image share i use exactly social.showPostDialog("twitter", "message", "url" ,"imgSrc", callback); and got black screen and the app don't lunch when i use social.showPostDialog(twitter, message, url ,imgSrc, callback); there is no black screen , the app lunch but the twitter share action not work and got the error js error js error line 1 colum 30 , 37 that's all :dango:

matrixreal commented 9 years ago

@finscn any news please ? i think we are not far from the goal !!! :dancers:

finscn commented 9 years ago

would you test on device?

matrixreal commented 9 years ago

i'm testing on real device

matrixreal commented 9 years ago

@finscn hi, here is what i have done and what i get

1) i'm using lastest version of your fork

2) i'm already logged in facebook and twitter app in my iphone (user and pass ok)

i'm using in the main js file (index.js) the following code

var social = new ejecta.social(); var message = "hello";

later in my app i'm using the call like : social.showPostDialog('twitter',message,'imgSrc');

this is the only one that work ... when i use social.showPostDialog("twitter",message,"imgSrc"); (with " and not ' i got error javascript , also when i use the word callback i got error javascript too ...

1) with social.showPostDialog('twitter',message,'imgSrc'); i get the post dialog but with no image like screenshoot 1

img_1831

(i already put an image.png that i would like to post in the app folder and in the project folder)

2) when i click on share (publier in french) i got the message on displayed + done like screenshoot 2

1

but after 2 or 3 seconds it seem that fail to post it on facebook (it say impossible to publish because fail to connect to facebook) and i got the screenshoot 3

img_1832

that is it ... i hope that will help and i think we are not far than the goal :dancer:

finscn commented 9 years ago

use:

social.showPostDialog('twitter', 'message', "http://you-want-to-share-URL", 'image/file.png');
finscn commented 9 years ago

there are 5 arguments : snsName ,message, shareUrl, imgSrc, callback if no message , shareUrl or imgSrc use null.

social.showPostDialog('twitter', 'message', null , 'image/file.png');

finscn commented 9 years ago

I can't visit twitter facebook, I'm so sorry for late replied

matrixreal commented 9 years ago

@finscn that's work thanks a lot

the last thing i want to ask you is how to take a screenshoot / snapshoot and save it to file.png (that can be used to be share with this method) ?

finscn commented 9 years ago

I think it's a little complex . I don't know how to do that

matrixreal commented 9 years ago

because i see your post here https://github.com/phoboslab/Ejecta/issues/210

finscn commented 9 years ago

@matrixreal https://github.com/phoboslab/Ejecta/issues/428

matrixreal commented 9 years ago

@finscn i use toDataURL(); and toDataURLHD(); call but it say "not supported for this context"

finscn commented 9 years ago

@matrixreal , please update . I add a function for save image/canvas

var appUtils = new Ejecta.AppUtils();
appUtils.saveImage(canvas, "${Documents}/test.png", function(filePath){
    console.log(filePath);
});

the canvas could be screen-canvas , offscreen-canvas , or Image object.

matrixreal commented 9 years ago

@finscn i sorry for my bad english but i don't understand so this call is to take screenshoot and save it right ?

matrixreal commented 9 years ago

got this

Sep 6 17:37:48 iPhone-4 Ejecta[7875] : CGImageCreate: invalid image size: 0 x 0. 2015-09-06 17:37:48.726 Swing Copters[7875:60b] JS LOG: /var/mobile/Applications/040170E3-CE92-47D7-A2A8-668F69868459/Documents/test.png

finscn commented 9 years ago

show me your code

matrixreal commented 9 years ago

when i'm using

var appUtils = new Ejecta.AppUtils(); appUtils.saveImage(canvas, "${Documents}/test.png", function(filePath){ console.log(filePath); }); just like that with "

i got 2015-09-06 18:23:26.370 Swing Copters[8011:60b] SyntaxError: JSON Parse error: Expected ']' at line 3695 in index.js

when i replace " by ' like that

var appUtils = new Ejecta.AppUtils(); appUtils.saveImage(canvas, '${Documents}/test.png', function(filePath){ console.log(filePath); });

i got

Sep 6 17:37:48 iPhone-4 Ejecta[7875] : CGImageCreate: invalid image size: 0 x 0. 2015-09-06 17:37:48.726 Swing Copters[7875:60b] JS LOG: /var/mobile/Applications/040170E3-CE92-47D7-A2A8-668F69868459/Documents/test.png

finscn commented 9 years ago

please init canvas , then draw something on it first.

matrixreal commented 9 years ago

how can i do it please ? thank you a lot

finscn commented 9 years ago

I think this is a basic question. if you don't know how to “initialize canvas and draw something” ,how do you use ejecta ?

Are you a javascript programer? Do you know how to use ejecta?

matrixreal commented 9 years ago

@finscn i'm so sorry ... i have bad english if you mean this

var canvas = document.getElementById('canvas'); canvas.width = w; canvas.height = h;

so it is already implemented on the main file (index.js)

finscn commented 9 years ago

what's value of w and h ?

matrixreal commented 9 years ago

@finscn hi thanks for reply w=window.innerWidth; h=window.innerHeight

finscn commented 9 years ago

do you draw something on The canvas?

matrixreal commented 9 years ago

yes of cource i have completely game from construct 2 and impact js they are drawn on the canvas like the screen shoot posted before you can see that the game is lunching so it's drawn on canvas no ?

finscn commented 9 years ago

I've no idea. I test it and everything is ok.

matrixreal commented 9 years ago

are you using webview ?

finscn commented 9 years ago

no。but i think it doesn't matter.

matrixreal commented 9 years ago

@finscn i will give it a test again thanks anyway

matrixreal commented 9 years ago

@finscn same again are you using '${Documents}/test.png' or "${Documents}/test.png" ?

finscn commented 9 years ago

@matrixreal , ' or " is not key point , I think.

all code in my testing index.js :


var width = window.innerWidth;
var height = window.innerHeight;
var canvas = document.getElementById('canvas');
canvas.width = width;
canvas.height = height;
canvas.retinaResolutionEnabled = true;
var context = canvas.getContext("2d");
context.fillStyle="#666666";
context.fillRect(0,0,width,height);

var appUtils = new Ejecta.AppUtils();
appUtils.saveImage(canvas, "${Documents}/test.png", function(filePath){
    console.log(filePath);
});
matrixreal commented 9 years ago

by adding this var context = canvas.getContext("2d"); the error goes and it say like it saved to image/test.png but if i use this image to share it show nothing

matrixreal commented 9 years ago

got this 2015-09-07 09:06:12.985 Swing Copters[709:60b] JS LOG: /var/mobile/Applications/F5FAAE3C-9FAC-4791-989B-259B3B1CA471/Swing Copters.app/App/image/test.png but when i want to share this image .... there is no image with the twitter with this dialogsocial.showPostDialog('twitter', 'message', "http://you-want-to-share-URL", 'image/test.png');

finscn commented 9 years ago

if you save image use "${Documents}/test.png" , when share, must also use it :

dialogsocial.showPostDialog('twitter', 'message', "http://you-want-to-share-URL", '${Documents}/test.png');
matrixreal commented 9 years ago

you mean social.dialog ? or dialogsocial ?

finscn commented 9 years ago

It's just a var name. you can use any name.