Ionic Instagram插件"无法读取属性' slice'未定义"

时间:2016-10-15 05:31:08

标签: android plugins ionic-framework instagram ngcordova

我正在使用Ionic,当我尝试通过ngCordova与Instagram插件分享图片时,这个错误发生在android上。我在网上看到的问题与我的一样,但没有找到任何解决方案,所以也许有人可以帮我解决这个问题。

10-14 20:29:51.202 4552-4552/? I/chromium: [INFO:CONSOLE(26794)] "TypeError: Cannot read property 'slice' of undefined
                                           at Object.Plugin.share (file:///android_asset/www/plugins/cordova-instagram-plugin/www/CDVInstagramPlugin.js:93:18)
                                           at Object.share (file:///android_asset/www/scripts/libs/ng-cordova.js:4805:17)
                                           at file:///android_asset/www/scripts/controllers/homeCtrl.js:206:31
                                           at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:56230:19
                                           at Object.ionic.Platform.ready (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2140:9)
                                           at Object.self.ready (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:56223:26)
                                           at home.shareInstagram (file:///android_asset/www/scripts/controllers/homeCtrl.js:205:26)
                                           at Object.$ionicPopup.show.buttons.onTap (file:///android_asset/www/scripts/controllers/homeCtrl.js:170:105)
                                           at Scope.extend.$buttonTapped (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:56771:45)
                                           at fn (eval at <anonymous> (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:27638:15), <anonymous>:4:386)", source: file:///android_asset/www/lib/ionic/js/ionic.bundle.js (26794)

1 个答案:

答案 0 :(得分:0)

好吧,也许对某人有帮助。在cordova instagram插件的描述中写道,我应该传递两个参数,如

share(imageData, imageCaption)

但这是一个错误,因为它应该作为参数的对象传递,而不是两个值:

 $cordovaInstagram.share({image: image.data, caption: image.caption}).then(function() {
          // Worked
          alert('instagram sharing worked');
        }, function(err) {
          // Didn't work
          alert('instagram error');
        });