Search code examples
javascriptangularjscordovaionic-frameworksocialshare

Ionic social share is undefined


I am trying to follow the tutorial example in ionic with the line

window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);

but I keep getting

ionic.bundle.js:20306 TypeError: Cannot read property 'socialsharing' of undefined

I guess I am missing something in the app.js to include the library?

angular.module('starter', ['ionic','leaflet-directive', 'ngCordova', ... ?

Do I need to load it in the above line? Do I have to load it into the controller as a module? I didnt find that on the tutorial and it's not clear?

I tried cordova plugin add multiple times, either as the package name or through git


Solution

  • Turns out I was looking into the wrong documentation. If using ionic, check ngCordova docs rather then the offical package documentations. They are not consistent.

    I had to add $cordovaSocialSharing to my controller and it worked on the device, not in the simulator and neither in my dev browser chrome.