In this section, we add the ability to share the session details through the device's native sharing options.
Add the social sharing plugin to your project:
$ ionic plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/
In session.html, wire the share tab to the shareNative function in the controllers.js via ng-click:
<a class="tab-item" ng-click="shareNative()">
<i class="icon ion-share"></i> Share
</a>
Open controllers.js and define the shareNative function to the sessionCtrl as follows:
$scope.shareNative = function() {
if (window.plugins && window.plugins.socialsharing) {
window.plugins.socialsharing.share("I'll be attending the session: " + $scope.session.title + ".",
'PhoneGap Day 2014', null, "http://pgday.phonegap.com/us2014",
function() {
console.log("Success")
},
function (error) {
console.log("Share fail " + error)
});
}
else console.log("Share plugin not available");
}
Test the Application
The options shown here will depend on your particular devices' native sharing options.