Social sharing


#1

Hi,

I can’t share using Ionic and I need some help from you guys.

My controller looks like this:

.controller(‘MainCtrl’, function($scope, $cordovaSocialSharing){

  ionic.Platform.ready(function() {

		$scope.share = function() {
			alert("Share");
			 $cordovaSocialSharing.share('This is my message', 'Subject', null, 'http://www.mylink.com');

		}

  });

In view, I have button:

<button ng-click="share()">Click me!</button>	

When I click in the browser I get error like: Cannot read property ‘socialsharing’ of undefined

I suppose I get this error because I’m testing in the browser. I tried to click a button on my mobile phone using Ionic View but when I click nothing happen. What is the problem?

Thanks!


#2

The plugin is not working in the Ionic View app, because the it isn’t supported yet. You can find a list of supported plugins here. I suggest that you run your app on a real device.

// Android
$ ionic run android

// iOS (don't forget to install ios-deploy)
$ ionic run ios --device

#3

You can make use of window.plugins.socialsharing object and call the functions like shareViaFacebook etc …this is working for me right now in all of my projects.

For more details and full code you can check the video here Social Sharing Plugin: Ionic App