0

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);
            }
        );
    }
});
4

3 回答 3

1

使用此代码它对我有用

第一步:将此插件添加到您的 config.xml 文件中

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

第二步:在社交功能下添加此代码

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

于 2017-01-18T18:08:11.873 回答
0

使用下面的代码它对我有用。我用whatsup

window.plugins.socialsharing.shareViaWhatsApp(text, 'image', null, function() {}, function(errormsg) {});
于 2017-01-18T09:50:30.670 回答
0

错误已解决。这是一个 Android 构建错误。我必须在 build.gradle 文件中添加一个依赖项。

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:+'
}

然后通过 CLI 再次安装它,它工作正常。谢谢你。

于 2017-01-19T06:45:44.703 回答