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

undefined is not an object (evaluating 'window.sqlitePlugin.openDatabase'), when using Cordova iOS 6.1.1 with custom scheme. #956

Open
simonwatt opened this issue Oct 6, 2020 · 5 comments

Comments

@simonwatt
Copy link

simonwatt commented Oct 6, 2020

I have upgraded to Cordova iOS 6.1.1. After doing this my app started getting CORS issues. To get around CORS issues I added custom scheme as recommended by the Cordova iOS 6.0.0 release notes:

Additionaly, WKURLSchemeHandler support has been introduced with this release. Using a custom scheme to serve your app content through fixes CORS issues that exist because of the strict security policies that WKWebView has applied to the file scheme. You can easily configure your Cordova project to use a custom scheme by setting the preference options scheme and hostname in the config.xml file.

<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />

My CORS issues have gone away, but now my app fails to open due to a JavaScript error with this plugin which I suspect is related to using the custom scheme.

Message: typeError: "undefined is not an object (evaluating 'window.sqlitePlugin.openDatabase')"
SourceURL: "app://localhost/main.c60b13ae740b88e19f4a.js"

(I don't currently have access to XCode logs, so above is just an alert from window.onerror).

This plugin works on earlier versions of Cordova iOS when I'm not using a custom scheme, and also works on Android, so I don't think it's an issue with how I call the plugin (I also can confirm I'm calling openDatabase after deviceready event fires).

@simonwatt
Copy link
Author

Possibly related to #949 , although 'reinstall the plugin' makes no difference for me.

@tom8henry Did you ever find a solution?

@simonwatt
Copy link
Author

simonwatt commented Oct 8, 2020

Interestingly, on rare occasions (maybe 1/20 times I open the app) it works without the above error (it also works on Android 100% of the time), leading me to believe it maybe is related to a race condition. I think it's possible deviceready is firing but the plugin is still not ready to have window.sqlitePlugin.openDatabase called. I have checked my code (and added logging) and I'm certain I'm not making the call until deviceready fires, but the behaviour I'm seeing indicates the plugin isn't loaded and ready to use.

@shamsundhar
Copy link

hi simonwatt, i am facing same issue. Please let me know, if you found any issue.

@QasimtyagiESS
Copy link

Hi
I have found the issue

call the plugin in or after deviceready function

@Willian199
Copy link

Same issue. Only occurs on iPad with iOS 14+

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

4 participants