2016-08-10 3 views
0

So bin ich neu bei Android-Programmierung und derzeit versucht, eine Funktion zu machen, meine Android-App mit Ionic Framework zu teilen. Diese ist der Ansicht:Ionic shareAnywhere-Taste funktioniert nicht

 <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> 

Dies ist `(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(); 
     }; 


    }) 
})();` 

Aber es funktioniert nicht, auf Chrome Konsole gesagt:

TypeError: Cannot read property 'socialsharing' of undefined 

Ich dachte, es ist nur ein Fehler von Cordova, aber wenn ich die App auf meinem Handy installiere, hat die Funktion nichts gemacht Was habe ich verpasst?

Antwort

1

Haben Sie es dem Projekt hinzugefügt? Die Befehlszeile lautet:

ionic plugin add cordova-plugin-x-socialsharing 
+0

Dank Pablo und E666. Aber die korrekte Syntax lautet: 'ionic plugin add cordova-plugin-x-socialsharing'. Ich habe deine Antwort bearbeitet. – Safira