Safira
Safira

Reputation: 275

Ionic shareAnywhere button not working

So I am new at android programming, and currently trying to make a function to share my android app using Ionic Framework. This is the view:

        <ion-item menu-close class="item item-icon-left" ng-click="shareApp('Aplikasi BeDA: ', '{{namaapk}}', '', 'https://play.google.com/store/apps/details?id={{apk}}')">               
           <i class="icon ion-android-share-alt {{appcolor}}"></i>
           <small>SHARE APLIKASI<small>                     
        </ion-item>

This is `(function() { 'use strict';

angular
    .module('bps.menu')
    .controller('MenuController', function($scope, $stateParams, $ionicHistory, $http, $cordovaAppRate, $cordovaSocialSharing, $ionicPopup, Config, Color) {
        var xhr = $http({method: 'get', url:'json/menu.json'});
        xhr.success(function(data){
          $scope.namaapk = Config.NamaAplikasi;
          $scope.apk = Config.GooglePlay;
          ...
          $scope.appcolor= Color.AppColor;
        });
        ...
        $scope.shareApp = function(message, subject, file, link) {
            $cordovaSocialSharing
            .share(message, subject, file, link+$scope.apk)
            .then(function(result) {
              // Success!
            }, function(err) {
                alert("Error. We're sorry.");
            });
        }
        ...
        $scope.goBack = function() {
          console.log('back');
          $ionicHistory.goBack();
        };


    })
})();`

But it's not working, on Chrome console it said:

TypeError: Cannot read property 'socialsharing' of undefined

I thought it's just a bug from Cordova. But when I install the app on my phone, the function didn't do anything. What have I missed?

Upvotes: 0

Views: 73

Answers (1)

Pablo
Pablo

Reputation: 28

Have you added it to the project? The command line is :

ionic plugin add cordova-plugin-x-socialsharing

Upvotes: 1

Related Questions