Skip to content Skip to sidebar Skip to footer

Android Phonegap Version 2.0 Or Higher Any Update For Share Plugin For Facebook , Twitter, Message Etc

I am trying to use the PhoneGap Share plugin for 2.0 version. I have implemented it but this is not work properly. This plugin is written in PhoneGap 1.0 and later version any new

Solution 1:

I am sharing my code which is working fine. Please refer This link for share plugin functionality and follow below given steps.

1- Place the JS file in the same folder of the MainActivity.java folder.

2- Place the Js file in the www folder and add it to the index.html folder.

3- Add the following line to the config.xml (if you are using new version of Phonegap) or plugins.xml (for old version of Phonegap):

4 - add html

<!DOCTYPE html><html><head><scripttype="text/javascript"src="js/libs/cordova-2.0.0.js"></script><scripttype="text/javascript"src="js/libs/jq_min.js"></script><scriptsrc="js/libs/share.js"></script><script>// Wait for Cordova to load//document.addEventListener("deviceready", onDeviceReady, false);

        // Cordova is ready//functiononDeviceReady() {

        }

        //share plugin for update status  functionshare(subject, text) { 
        window.plugins.share.show({
        subject: subject,
        text: text},
        function() {
        alert("sent success");}, // Success functionfunction() {alert('Share failed')} // Failure function
         );
        };

        //Send message on facebook
        $(document).ready(function() {
        $("button#sendFacebook").click(function(){
        var txtsub = $("input#txtsub").attr("value");
        var txtmsg = $("#txtmsg").val();
        share(txtsub, txtmsg);
    });

    });
    </script></head><body><inputid="txtsub"type="text"placeholder="Enter Subject"maxlength="20"required /><br/><br/><textareaplaceholder="Enter Message"id="txtmsg"rows="4"cols="25"></textarea><br/><buttonid="sendFacebook">Update Status </button></body></html>

and test this plugin for Face book,twitter,gmail etc. & enjoy :).

Let me know if you have any query.

Solution 2:

it seems that you are not implementing the plugin in a proper way, just try the following steps:

1- Put the java file in the same folder of the MainActivity.java

2- Put the Js file in the www folder and add it to the index.html

3- Add the following line to the config.xml (if you are using new version of Phonegap) or plugins.xml (for old version of Phonegap):

<pluginname="Share"value="Path_Of_Your_Project.share.Share"/>

4- Just write the following into your JS file:

functionshare(subject, text) { 
  window.plugins.share.show({
    subject: subject,
    text: text},
    function() {}, // Success functionfunction() {alert('Share failed')} // Failure function
  );
};  

To Call the function:

$("#share_id").onClick(function(){
   share("subject", "text");
});

As simple as this.

Post a Comment for "Android Phonegap Version 2.0 Or Higher Any Update For Share Plugin For Facebook , Twitter, Message Etc"