I'm using the plugin cordovaSocialShare of NgCordova to make sharing on social networks in my application. The problem is that I don’t have actions returned, and when analyzing the ADB logs, it returns me the following error:
I / chromium (3635): [INFO: ISLAND (20306)] "TypeError: Can not call method 'canShareVia' of undefined
I / chromium (3635): Scope at $ scope.shareViaWhatsapp. (File: ///android_asset/www/js/app.js: 22: 31)
Look at the code:
HTML
<ion-option-button class="button-dark button-facebook" ng-click="shareAnywhere()">
<i class="icon ion-social-facebook icon-facebook"></i>
</ion-option-button>
AngularJS
$ionicPlatform.ready(function(){
$scope.shareViaWhatsapp = function(message, image, link) {
$cordovaSocialSharing.canShareVia("whatsapp", message, image, link).then(function(result) {
$cordovaSocialSharing.shareViaWhatsapp(message, image, link);
}, function(error) {
alert("Cannot share on Whatsapp");
});
}
$scope.shareAnywhere = function() {
$cordovaSocialSharing.share("This is your message", "This is your subject", "www/imagefile.png", "http://blog.nraboy.com");
}});
Someone could help me please?
Anyway, again, I decided the problem by myself ...
The result:
In command line:
ionic plugin add cordova-plugin-SocialSharing
AngularJS:
$scope.share = function($title, $excerpt, $permalink) {
$ionicListDelegate.closeOptionButtons();
window.plugins.socialsharing.share($title, $excerpt, null, $permalink);
}
HTML:
<ion-option-button class="button-positive button-share" ng-click="share('{{item.title}}', '{{item.excerpt}}', '{{item.permalink}}')">
<i class="icon ion-android-share-alt"></i>
</ion-option-button>