Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: savedFS is not a function #205

Open
Defcon0 opened this issue Apr 1, 2017 · 18 comments
Open

Uncaught TypeError: savedFS is not a function #205

Defcon0 opened this issue Apr 1, 2017 · 18 comments

Comments

@Defcon0
Copy link

Defcon0 commented Apr 1, 2017

When running imgcache I get:

Uncaught TypeError: savedFS is not a function
at imgcache.js:633

Am I doing something wrong or is it a bug?

@chrisben
Copy link
Owner

chrisben commented Apr 1, 2017

Could you please explain how you're running imgcache?
This part of code should be triggered when running with Chrome.

If you run the following in your browser console, what response do you get ?
window.requestFileSystem || window.webkitRequestFileSystem

@Defcon0
Copy link
Author

Defcon0 commented Apr 1, 2017

I use the angular wrapper (angular-imgcache.js#^1.1.0) and get the error when using the Chrome developer tools after running my ionic app on an Android device. If you need further detail, don't hesitate to contact me again :-)

Initially I get:

INFO: ImgCache initialising
imgcache.js:49 INFO: LocalFileSystem opened
imgcache.js:49 INFO: Local cache folder opened: cdvfile://localhost/persistent/imgcache/
imgcache.js:49 INFO: .nomedia file created.

After running
window.requestFileSystem || window.webkitRequestFileSystem

I get:

function (type, size, successCallback, errorCallback) {
argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
var fail = function(code) {
if (errorCallback) {

Strange thing is that it doesn't happen everytime. Just now and then. But when the error message pops up I mentioned in my first post, window.requestFileSystem || window.webkitRequestFileSystem returns undefined.

@chrisben
Copy link
Owner

chrisben commented Apr 1, 2017

I've just merged a PR that fixes browser detection for ionic into master, could you please check with that version?

@adascal
Copy link

adascal commented Sep 12, 2017

@chrisben Problem seems to be not fixed. Still can see it on Android devices

@ghost
Copy link

ghost commented Oct 25, 2017

I'm also seeing this happen, even with the latest version of ionic-img-cache installed.

@jyve
Copy link

jyve commented Oct 28, 2017

Same issue here, with version 1.2.0

@csicky
Copy link

csicky commented Nov 8, 2017

Hi, I had the same issue. window.requestFileSystem was undefined and because of this it entered the wrong path, in Chrome instead of Cordova and savedFS also was undefined.

The solution for me was to properly wait for deviceready event and only then to init ImageCache and start using it. I hope it helps others with same problem.

Very helpful library, thx for making it!

@chrisben
Copy link
Owner

chrisben commented Nov 9, 2017

Thanks @csicky for pointing this out. It's actually part of the documentation:

If you're using imgcache.js with PhoneGap/Cordova, ImgCache.init() must be called after the onDeviceReady event has been triggered, not before!

@Defcon0
Copy link
Author

Defcon0 commented Nov 9, 2017

Maybe this should be put somewhere more prominent :-)

@chrisben
Copy link
Owner

chrisben commented Nov 9, 2017

I also accept pull requests for the README :)
@Defcon0 : did that fix your problem ? Let me know so that we can close this issue.

@Defcon0
Copy link
Author

Defcon0 commented Nov 9, 2017

@chrisben Ah, ok, I'll check later on today (or on weekend) and reply afterwards.

@chrisben
Copy link
Owner

chrisben commented Nov 9, 2017

README paragraph now bold. There's also a bold statement in the CORDOVA.md document.

By the way I also merged my long standing 2.x branch, 2.0.0 is out now!

@Defcon0
Copy link
Author

Defcon0 commented Nov 10, 2017

@chrisben Still no luck :-( The problem occurs with this code:

document.addEventListener('deviceready', function() {
    ImgCache.$init();
});

called in app.module.js.

I have imgcache.js 1.1.0 and angular-imgcache 1.2.0.

@renanmoraes
Copy link

for me it also does not work at all on android.

@yurii-zadryhun
Copy link

yurii-zadryhun commented Mar 26, 2018

I'm also seeing this problem on android (cordova). I call init function when deviceready has been triggered.
image

@chrisben
Copy link
Owner

chrisben commented May 6, 2018

Could someone please test the following and check what the console logs display:

document.addEventListener('deviceready', function() {
    // init
   ImgCache.init();
   console.log('isCordova?', ImgCache.helpers.isCordova());
   console.log('requestFileSystem', window.requestFileSystem);
   console.log('cordova', typeof cordova);
   console.log('phonegap', typeof phonegap);
   console.log('platformId', (cordova||phonegap).platformId);
});

@ragunathans
Copy link

You need to install following plugins to fix the savedFS is not a function issue.

ionic cordova plugin add cordova-plugin-file --save
ionic cordova plugin add cordova-plugin-device --save
ionic cordova plugin add cordova-plugin-file-transfer --save

@vdias38
Copy link

vdias38 commented Sep 23, 2020

I've faced this issue, but found that cordova.js was missing on my app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants