1

I'm developing an app for FirefoxOS. This app needs a button that, when pressed, shares some text in social networks and email.

I'm using this code I found somewhere:

var share = document.querySelector("#share"); 
if (share)
{
     share.onclick = function () 
     {
         var sharing = new MozActivity({
         name: "share",
         data: 
         {
             //type: "url", // Possibly text/html in future versions,
             number: 1,
             url: "http://robertnyman.com"
         }
         });
     }
}

It kind of works and I successfully shared pictures. This code opens a menu with all the apps that are available for sharing (Facebook, Twitter, etc). Then you can select any app and it will open that app with an empty textfield that the user can fill with text to share. But I cannot share predefined text at all. I cannot pass this predefined text to the other apps.

As you can see, there's a type parameter that's commented and it says that it'll be available in future versions.

Do you guys have any idea of how to include text in the data variable (or somewhere else) so it can be shared?

Thanks everyone!

jmoukel
  • 794
  • 6
  • 18
  • Have you seen the new activity example here: http://stackoverflow.com/questions/16914627/send-email-from-firefoxos-app-with-content That should handle the email piece. – Jason Weathersby Jul 07 '14 at 16:34
  • Yes, I saw that already, thanks! ... I was looking for a generic way to use all the social networks at once. – jmoukel Jul 07 '14 at 20:02

1 Answers1

2

I am not sure the Twitter Firefox OS App has a field for the text for the share activity. Another option is to compose the twitter URL and then open it. For example:

var twitterURL = encodeURI("https://twitter.com/intent/tweet?text=test tweet");
        var openURL = new MozActivity({
            name: "view",
            data: {
               type: "url", 
               url: twitterURL
            }
        })
Jason Weathersby
  • 1,071
  • 5
  • 5
  • Yes, I'm seriously considering that option. Because I haven't been able to find a generic way to handle all the social networks + email + sms at once... Thanks Jason! – jmoukel Jul 07 '14 at 20:03