Open pfallasro opened 9 years ago
I have the same issue. Are you running it in a browser or on a device? I am trying from an ionic app running on an android device.
I tried both through the ngCordova wrapper as well as without. Tried to remove and install both the platforms as well as the plugin as was suggested somewhere but still doesn't work.
When I print the window object to the console and run it on an android device, I do see that it contains the imagePicker attribute including the getPictures function:
imagePicker: ImagePicker__proto__: Objectconstructor: function () {getPictures: function (success, fail, options) {arguments: nullcaller: nulllength: 3name: ""prototype: Object__proto__: function Empty() {}<function scope>__proto__: Object
Therefore I don't quite understand why I get this error:
TypeError: Cannot read property 'getPictures' of undefined
at Object.getPictures (file:///android_asset/www/lib/ngCordova/dist/ng-cordova.js:4378:28)
at home.pickImages (file:///android_asset/www/js/app.js:44:27)
at new <anonymous> (file:///android_asset/www/js/app.js:54:10)
at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:13282:17)
at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:13290:27)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17846:28
at file:///android_asset/www/js/angular-ui-router.min.js:7:23333
at invokeLinkFn (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17482:9)
at nodeLinkFn (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:16982:11)
at compositeLinkFn (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:16373:13)
I'm getting the same error, also running ionic 1.1.1, cordova 5.3.3 and android 4.4.4. In my case it happens right when window.imagePicker.getPictures() is called.
@MoPHL did you manage to figure it out by chance? Just making sure, you are running it on a real device right? not a simulator?
Yes, unfortunately I'm not sure the same solution will work for you. I am working on a windows computer and the project is in a folder shared between my machine and a local mac computer so that I can quickly compile the iOS version. What caused my issue was, I assume, some file permission problem and the solution was to delete and recreate the iOS platform on the mac computer. I have since run into the plugin not working on iOS when it works on android issue a few times more and this method solved it for me each time. Sorry if it wasn't of much help to your specific situation.
@MoPHL thanks for you explanation but indeed I have a different case.
Actually just now I had another look at it and realised that I didn't wrap my call to the picker in $ionicPlatform.ready like is clearly written in the ngCordova docs. So pretty stupid haha
Anyway hope this helps the next person...
As far as I am concerned this issue can be closed.
It is also worth noting that if you use Ionic View, there is only a select few plugins that will work, and this is not one of them (see http://docs.ionic.io/docs/view-usage). Uploading the app through USB did the trick for me.
This is happening to me. Im running my app with phonegap serve, and then testing it with my phone with the Phonegap app.
I am having the same issue as @dalepo. Does anyone have a fix yet? wrapping the function in $ionicPlatform.ready as @abhayastudios recommended isn't helping.
Also experiencing same problem testing on my nexus 5X. Cannot read property 'getPictures' of undefined but $cordovaImagePicker is an object with that method when logged to console.
`$ionicPlatform.ready(function() { console.log($cordovaImagePicker);
var options = {
maximumImagesCount: 1,
width: 150,
height: 150,
quality: 100
};
console.log(options);
console.log('here we go...');
$cordovaImagePicker.getPictures(options)
.then(function(results) {
console.log('it worked!'); // Never gets here
for (var i = 0; i < results.length; i++) {
console.log(results[i]);
}
}, function(error) {
console.log(error);
});
});`
@seanmerron You are running your app on your nexus device? When I output $cordovaImagePicker to the console in regular Chrome I also see the method but still it doesn't work. It works only on Cordova devices. What gets outputted when you do something like below?
var photo=this;
photo.isCordovaDevice = function() {
return typeof(device)!=="undefined" && device.hasOwnProperty('cordova');
}
photo.pickImages() {
if (!photo.isCordovaDevice()) { console.warn('$cordovaImagePicker is not supported on this device!'); }
else {
console.info('$cordovaImagePicker is not supported on this device!');
$cordovaImagePicker.getPictures(options).then(function (results) {
// success
}, function(error) {
// error getting photos
});
}
}
@abhayastudios Thank you for getting back to me! I apologize about the delay, I tried to clean my keyboard and it shorted out and I finally got it back up and running. I couldn't run your exact code but after installing the device plugin and console.log(device) I see the cordova version is 5.1.0 on my Nexus 5X device that is having the problem so it appears cordova is on the device. I'm using version 6.0.0 of the cordova CLI in my app with version 1.1.0 of the imagepicker.
am having the same issue and on dedline could "some one save me"_____------"the song
am getting ionic.bundle.js:26794 TypeError: Cannot read property 'getPictures' of undefined
at Object.getPictures (ng-cordova.js:4512)
at new
am having the same issue and have no idea to deal with it.
Any solutions for Cannot read property 'imagePicker' of undefined?
At this time, none of this solutions working for me
I have the same problem, have you solved it?
yeah i figured u dont just use it in the browser
On Mon, Oct 9, 2017 at 2:36 AM, AmayChan notifications@github.com wrote:
I have the same problem, have you solved it?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wymsee/cordova-imagePicker/issues/102#issuecomment-335053472, or mute the thread https://github.com/notifications/unsubscribe-auth/ALCiXrTm6lDQXA8nMnd-82eMDbG0Dm8Nks5sqXicgaJpZM4GietM .
Getting the following error when I try to call window.imagePicker.getPictures ().
Does anyone know how to solve this ?
TypeError: Cannot read property 'getPictures' of undefined at Scope.$scope.selImages (controllers.js:397) at $parseFunctionCall (ionic.bundle.js:21172) at ionic.bundle.js:53674 at Scope.promises.$get.Scope.$eval (ionic.bundle.js:23228) at Scope.promises.$get.Scope.$apply (ionic.bundle.js:23327) at HTMLButtonElement. (ionic.bundle.js:53673)
at HTMLButtonElement.eventHandler (ionic.bundle.js:11841)
at triggerMouseEvent (ionic.bundle.js:2865)
at tapClick (ionic.bundle.js:2854)
at HTMLDocument.tapTouchEnd (ionic.bundle.js:2977)