I'm having trouble with my Cordova application accessing window.cordova.plugins with Javascript.
When my app starts, the webview immediately redirects using the following, meaning I no longer have access to window.cordova.plugins:
window.location.href = "https://www.example.com/";
Previously I remedied this using cordova-plugin-remote-injection which injected Cordova and any other Javascript files I needed, but I have found it now interferes with regular Javascript on my site (primarily Apple Pay on the web). Additionally the plugin has been deprecated so doesn't receive updates.
Can someone suggest a current and preferably future proof way of being able to access window.cordova.plugins from my remote site? This would need to work on both ANDROID and IOS.
Thanks!
Although it's not an ideal solution, I've solved the problem by uploading the Cordova Javascript files to my web server, and included them into my webpage. Cordova as well as all plugins are now accessible.
For anyone wanting to do the same:
That's all. "cordova.js" loads "cordova_plugins.js" which in turn loads all accompanying plugin Javascript files.
The reasons why it's not an ideal solution:
All said, it does seem to work.