Ejecta icon indicating copy to clipboard operation
Ejecta copied to clipboard

[QUESTION] Social share options

Open rungo73 opened this issue 10 years ago • 20 comments

I would like to bind SLComposeViewController to Ejecta. I want to post string from Ejecta with score to social apps for example in JS: var score = 1234; var message = "You have scored" + score + "playing my game"; And then send message to iOS share options to be populated in the selected social app. I use Javascript but have little knowledge of objective-C.

Many thanks in advance.

rungo73 avatar Apr 14 '15 05:04 rungo73

My fork version has this feature. It used the Build-in Social API of iOS.

finscn avatar Apr 14 '15 07:04 finscn

you can see : https://github.com/finscn/Ejecta/blob/master/Extension/EJBindingSocial.m

Because in China We can't use facebook and twitter. So , I don't test it enough , Sorry

finscn avatar Apr 14 '15 07:04 finscn

This is working great for me 😀👍

Greatly appreciated.

Regards, Tom.

On Tuesday, April 14, 2015, finscn [email protected] wrote:

you can see : https://github.com/finscn/Ejecta/blob/master/Extension/EJBindingSocial.m

Because in China We can't use facebook and twitter. So , I don't test it enough , Sorry

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/481#issuecomment-92677494.

rungo73 avatar Apr 14 '15 08:04 rungo73

@rungo73 can you tel us how you done sending message to social apple share ? what is the javasciprt code u use to call or send this ? i need it too thanks in advance

matrixreal avatar Apr 14 '15 22:04 matrixreal

I added this method to EJBindingSocial.m:

/////////////////////////////////

EJ_BIND_FUNCTION(openShare, ctx, argc, argv){

NSString *score = JSValueToNSString(ctx, argv[0]);


UIActivityViewController *activityViewController = [[

UIActivityViewController alloc] initWithActivityItems:@[score]

          applicationActivities:nil];

[scriptView.window.rootViewController presentViewController

:activityViewController

                   animated:YES

                 completion:^{

                     NSLog(@"completed.");

                 }];

return NULL;

}

//////////////////////////// then in main.js you can do this which will open iOS default share options view, populated with supplied text

ig.global.social = new Ejecta.Social();

var message = ("Put in your message to share here");

ig.global.social.openShare(message);

@finscn this would be good to add to your fork.

On Wed, Apr 15, 2015 at 8:38 AM, MATRIX.REAL [email protected] wrote:

@rungo73 https://github.com/rungo73 can you tel us how you done sending message to social apple share ? what is the javasciprt code u use to call or send this ? i need it too thanks in advance

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/481#issuecomment-93098443.

rungo73 avatar Apr 15 '15 04:04 rungo73

@rungo73 , thanks , I add the code like this, I think it's better (you could do callback):

EJ_BIND_FUNCTION(openShare, ctx, argc, argv){

    NSString *message = JSValueToNSString(ctx, argv[0]);
    JSObjectRef callback = nil;
    if (argc > 1){
        callback = JSValueToObject(ctx, argv[1], NULL);
        if (callback) {
            JSValueProtect(ctx, callback);
        }
    }

    UIActivityViewController *activityViewController = [
         [UIActivityViewController alloc] initWithActivityItems:@[message] applicationActivities:nil
    ];

    [scriptView.window.rootViewController
         presentViewController:activityViewController
         animated:YES
         completion:^{
             if (callback){
                 [scriptView invokeCallback:callback thisObject:NULL argc:0 argv:nil];
                 JSValueUnprotect(scriptView.jsGlobalContext, callback);
             }
         }
     ];

    return NULL;

}

js code:

   var social=new Ejecta.Social();
   social.openShare("test", function(){
           console.log("opened");
    });

finscn avatar Apr 15 '15 05:04 finscn

@finscn thanks a lot that work fine but with little changes js code have to be like that : var social=new Ejecta.Social(); social.openShare("test", function(){ console.log("opened"); }); var message = ("Put in your message to share here");

@rungo73 thanks a lot but i when the default share option apear there is no facebook and no twitter only text message and mail ???

matrixreal avatar Apr 15 '15 06:04 matrixreal

@matrixreal you mean :

var social=new Ejecta.Social();

var message = "your message to share";

social.openShare(message,  function(){
   console.log("opened");
});

That's ok.

finscn avatar Apr 15 '15 06:04 finscn

it will only show if you have twitter or facebook apps installed on your device.

On Wed, Apr 15, 2015 at 4:27 PM, MATRIX.REAL [email protected] wrote:

@finscn https://github.com/finscn thanks a lot that work fine but with little changes js code have to be like that : var social=new Ejecta.Social(); social.openShare("test", function(){ console.log("opened"); }); var message = ("Put in your message to share here");

@rungo73 https://github.com/rungo73 thanks a lot but i when the default share option apear there is no facebook and no twitter only text message and mail ???

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/481#issuecomment-93217950.

rungo73 avatar Apr 15 '15 06:04 rungo73

@finscn yes exactly but i done it only by :

var social=new Ejecta.Social();

var message = "your message to share";

social.openShare(message);

@rungo73 mmmm thats okay but i think putting direct link call on browser is better ... some people have not fb or twitter installed ...

matrixreal avatar Apr 15 '15 06:04 matrixreal

@mattix.real You are correct to cover your bases but I find that users who care to post to social services will have those apps installed. I don't know of any tweeters who don't have a Twitter app installed on their device for example.

On Wednesday, April 15, 2015, MATRIX.REAL [email protected] wrote:

@finscn https://github.com/finscn yes exactly but i done it only by :

var social=new Ejecta.Social();

var message = "your message to share";

social.openShare(message);

@rungo73 https://github.com/rungo73 mmmm thats okay but i think putting direct link call on browser is better ... some people have not fb or twitter installed ...

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/481#issuecomment-93219957.

rungo73 avatar Apr 15 '15 07:04 rungo73

@rungo73 even with facebook and twitter installed i have not see them on apple share options any solutions please ?

matrixreal avatar Apr 15 '15 07:04 matrixreal

@matrix.real what version iOS are you running ? Might need a fallback, I'll investigate.

On Wednesday, April 15, 2015, MATRIX.REAL [email protected] wrote:

@rungo73 https://github.com/rungo73 even with facebook and twitter installed i have not see them on apple share options any solutions please ?

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/481#issuecomment-93250362.

rungo73 avatar Apr 15 '15 10:04 rungo73

@matrixreal , the callback is optional, you can just use one argument.

finscn avatar Apr 15 '15 13:04 finscn

@rungo73 ios 7

matrixreal avatar Apr 15 '15 16:04 matrixreal

@rungo73 hi any news ? still get the apple share option but only with message send option (there is no other options) waiting for your reply thanks @phoboslab any suggestions ? thanks all in advance

matrixreal avatar Apr 16 '15 12:04 matrixreal

@matrix.real see this post..

http://stackoverflow.com/questions/18987596/uiactivityviewcontroller-doesnt-show-fb-and-twitter-on-ios-7 On Thu, 16 Apr 2015 at 9:40 pm MATRIX.REAL [email protected] wrote:

@rungo73 https://github.com/rungo73 hi any news ? still get the apple share option but only with message send option (there is no other options) waiting for your reply thanks @phoboslab https://github.com/phoboslab any suggestions ? thanks all in advance

— Reply to this email directly or view it on GitHub https://github.com/phoboslab/Ejecta/issues/481#issuecomment-93718644.

rungo73 avatar Apr 16 '15 14:04 rungo73

Hi, where I can download social share plugin fo construct 2 ?

Pasha187 avatar May 19 '15 18:05 Pasha187

@Pasha187 , my fork version of Ejecta https://github.com/finscn/Ejecta

finscn avatar May 20 '15 02:05 finscn

How to realize this function, it is possible an example on mail: [email protected]. I don't know as to realize social share :/

Pasha187 avatar May 20 '15 05:05 Pasha187