2016-08-17 11 views
4

撮影した写真をInstagramに共有しようとしています。私はインストールしましたsocial share plugin from ngCordova website写真をInstagramとIonicで共有する方法

しかし、私はそれを動作させることができません。それを実行するとエラーは発生しません。 私は成功の応答を得るが、イメージはInstagramの壁に掲示されていない。

ログからの印刷画面です(xcode - >実際のデバイスからテストまで実行中)。 enter image description here

私が間違っていることを誰でも見ることができますか?ここで

は私のコントローラのコードの一部です:

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

あなたはNG-コルドバが欠落していることができますか? –

+0

いいえ、私のapp.jsファイルに追加しました – GY22

+0

あなたが問題になっているエラーを追加してください。 –

答えて

1
module.controller('ThisCtrl', function($scope, $cordovaInstagram) { 
     // Get image from camera, base64 is good. See the 
     // $cordovaCamera docs for more info 
     $cordovaInstagram.share($scope.image.data, $scope.image.caption).then(function() { 
     // Worked 
     }, function(err) { 
     // Didn't work 
     }); 
    }) 
+0

そしてこのプラグインを追加する必要があります。(cordova plugin add https://github.com/vstirbu/InstagramPlugin.git) – imtiyaz

+0

そのプラグインは既にインストールされています – GY22

1

コルドバのdevicereadyイベント内でプラグインの呼び出しをラップします。プラグインを呼び出す前にデバイスが完全にロードされていることを確認します。

document.addEventListener("deviceready", function() { 
    // your plugin call here 
}); 

また、より多くの情報のためにこれを読んで$ionicPlatform.ready(function() {});

を使用することができます:ngCordova common issues

関連する問題