Angularjs 如何与爱奥尼亚分享照片到Instagram

Angularjs 如何与爱奥尼亚分享照片到Instagram,angularjs,ionic-framework,ngcordova,Angularjs,Ionic Framework,Ngcordova,我正在尝试将拍摄的照片分享给Instagram。我已经安装了 但我无法让它工作。运行它时,我没有收到任何错误。 我得到了一个成功的回复,但是照片没有贴在Instagram的墙上 下面是日志的打印屏幕(xcode->从实际设备运行到测试)。 有人能看出我做错了什么吗 以下是我的控制器代码的一部分: app.controller('CameraCtrl', function($scope, $cordovaCamera, $cordovaSocialSharing, $rootScope, $st

我正在尝试将拍摄的照片分享给Instagram。我已经安装了

但我无法让它工作。运行它时,我没有收到任何错误。 我得到了一个成功的回复,但是照片没有贴在Instagram的墙上

下面是日志的打印屏幕(xcode->从实际设备运行到测试)。

有人能看出我做错了什么吗

以下是我的控制器代码的一部分:

app.controller('CameraCtrl', function($scope, $cordovaCamera, $cordovaSocialSharing, $rootScope, $state){

  $scope.takePicture = function(){
    var options = {
        quality: 75,
        destinationType: Camera.DestinationType.DATA_URI,
        sourceType: Camera.PictureSourceType.CAMERA,
        encodingType: Camera.EncodingType.JPEG,
        saveToPhotoAlbum: true,
        correctOrientation:true
    };
    $cordovaCamera.getPicture(options) 
      .then(function(imageURI){
          var imagePlaceholder = document.getElementById('placeholderPicture');
          imagePlaceholder.src = imageURI;
          $rootScope.imgShare = imageURI;
          //$scope.imgURI = "data:image/jpeg;base64," + imageURI;
          //$state.go('app.camera', {image: $scope.imgURI});
          //console.log('camera data: ' + angular.toJson(imageURI));
      },  function(error){
          console.log('error camera data: ' + angular.toJson(imageURI));
    });
  }

$scope.shareViaInstagram = function(message, image){
    socialType = "instagram";
    message = "test";
    image = $rootScope.imgShare;

     $cordovaSocialSharing.shareVia(socialType, message, image, null).then(function(result) {
      console.log('image shared to Instagram ', result);
      console.log('dddd', image);
      console.log('######', $rootScope.imgShare);
      //$state.go('app.finish');
}, function(err) {
      console.log('error in sharing to Instagram ', err);
});

  }

});
我的html代码的一部分:

<div class="wrapperCamera">
        <div class="cameraContent padding">
            <img id="placeholderPicture" ng-src="{{imgShare}}">
            <br>
            <h2 class="customH2Camera">looking good!</h2>
            <br><br>
            <div class="socialIcons">
                <a href="" ng-click="shareViaInstagram(null, null, imgShare, null)"><img src="img/iconInstagram.svg" width="40"></a>
                &nbsp;&nbsp;&nbsp;
                <a href="" ng-click="shareViaFacebook(null, null, imgShare, null)"><img src="img/iconFacebook.svg" width="40"></a>
            </div>
        </div><!-- end cameraContent -->
    </div><!-- end WrapperCamera -->    


看起来不错!


在cordova的DeviceRady事件中包装您的插件调用。它确保在调用插件之前设备已完全加载

document.addEventListener("deviceready", function () { 
  // your plugin call here 
});
您还可以使用
$ionicPlatform.ready(function(){})


阅读此内容以了解更多信息:

可能是您缺少ng cordova?不是,我在app.js文件中添加了它。请添加错误,说明您的问题。@HardikVaghani。这就是我没有得到的错误尝试用
try-catch
block包装方法。你需要添加这个插件。。(cordova插件添加)
document.addEventListener("deviceready", function () { 
  // your plugin call here 
});