[英]cordova/phonegap app - load js css and html from server
I'm developing an cordova app for Android which has a lot of logic (js) and design (html/css) same as my web application. 我正在为Android开发Cordova应用,该应用具有与我的Web应用相同的逻辑(js)和设计(html / css)。 I want to share these assets among web app and android app.
我想在网络应用程序和Android应用程序之间共享这些资产。 Now I had compiled all these js and css in apk, but when some code is changed, I have to prepare an update and put in the play store.
现在,我已经在apk中编译了所有这些js和css,但是当某些代码更改时,我必须准备一个更新并将其放入Play商店。 If it would be possible to load code and css from server after app started, it would reduce need for upgrading.
如果有可能在应用启动后从服务器加载代码和CSS,则将减少升级需求。 Is there any way?
有什么办法吗?
I'm considering loading shared resources via ajax and dynamically creating stylesheets and scripts in DOM, but maybe there is better approach, isn't it? 我正在考虑通过ajax加载共享资源并在DOM中动态创建样式表和脚本,但是也许有更好的方法,不是吗?
You could download the files from server every time, but i think that is not what you want because it would not be availibe offline at all and if the app it big and the connection bad it will take much time to download. 您可以每次从服务器下载文件,但是我认为这不是您想要的,因为它根本无法脱机使用,如果应用程序很大且连接不良,则将花费大量时间来下载。
a better way is to download the files if they change. 更好的方法是在文件更改时下载文件。 you can do that with FileTransfer .download() yourself or use a ready solution like the cordova-standalone-hydration
您可以自己使用FileTransfer .download()进行操作,也可以使用像cordova-standalone-hydration这样的现成解决方案
BUT your app will not be accepted by for example Apple because they deny an app with code they can not check 但是您的应用程序将不会被例如Apple接受,因为它们会拒绝带有无法检查代码的应用程序
I found a plugin where you can update all your files in the WWW folder on startup or later. 我找到了一个插件,您可以在启动时或以后在WWW文件夹中更新所有文件。
Link: https://www.npmjs.com/package/cordova-plugin-dynamic-update 链接: https : //www.npmjs.com/package/cordova-plugin-dynamic-update
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.