0
votes

Using Social Sharing plugin of ngCordova. Installed it manually using config.xml following : https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/blob/master/README.md Whenever I try to use the following function,it is always entering into function(err)

View code :

<ion-pane>
  <ion-header-bar class="bar-calm">
    <h1 class="title">SMS</h1>
  </ion-header-bar>
  <ion-content class="has-header">

  <ion-list>
     <label class="item item-input item-input-stacked item-stable">
      <span class="input-label"></span>
      <input type="number" placeholder="Your number" ng-model="sms.num">
    </label>
    <label class="item item-input item-input-stacked item-stable">
      <span class="input-label"></span>
      <input type="text" placeholder="Your message" ng-model="sms.msg">
    </label>
    <button class="button button-block button-dark" ng-click="send()"> Send </button>
    <button class="button button-block button-dark" ng-click="social()"> Social </button>
  </ion-list>
  </ion-content>
</ion-pane>

Angular Code:

.controller('ctrl', function($scope,$cordovaSms,$cordovaSplashscreen,$cordovaSocialSharing){

    $scope.social = function(){

        $cordovaSocialSharing.share("This is your message", "This is your subject", "www/img/ionic.png", "https://www.google.com")
        .then(
            function(result) {
                console.log("Success");
                console.log(result);
            }, 
            function(err) {
                // An error occurred. Show a message to the user
                console.log("error : "+err);
            }
        );
    }
});
3
Hi you need to test that functionality in real deviceManoj Rejinthala
I am actually testing it in an android device.And with the help of chrome webview I can access the console too.PRANSHU MIDHA
what is the error it is givingManoj Rejinthala
When it is trying to execute the function Instead of entering into: .then(function(result) { console.log("Success"); console.log(result); It is entering into : function(err) { console.log("error : "+err); } And giving errorPRANSHU MIDHA
DON'T install it manually. There's never a good reason for that anymore.Eddy Verbruggen

3 Answers

1
votes

Use This Code Its worked for me

1st step : add this plugin to your config.xml file

<gap:plugin name="cordova-plugin-x-socialsharing" source="npm" />

2nd step: Add this code under social function

window.plugins.socialsharing.share('Choose The App','Share It','www/img/ionic.png', 'http://www.x-services.nl');

0
votes

use the below code it worked form me. I used for whatsup

window.plugins.socialsharing.shareViaWhatsApp(text, 'image', null, function() {}, function(errormsg) {});
0
votes

The error is resolved. It was an Android build error. I had to add a dependency in build.gradle file.

dependencies {
    //
    // IDE setting pulls in the specific version of v4 support you have installed:
    //
    //compile 'com.android.support:support-v4:21.0.3'

    //
    // generic directive pulls in any available version of v4 support:
    //
    compile 'com.android.support:support-v4:+'
}

Then installed it again via CLI and it worked fine. Thank You.