serving cordova app www folder remotely

感情迁移 提交于 2019-12-04 20:20:57

This can be done by simply loading the remote site using

window.document.location = http://yoursite.com

from the Phonegap app

There are a few more steps required to allow the Phonegap API functions to work from your remote app.

  1. Build your remote app using Sencha CMD
  2. Deploy the build files on your server.
  3. Copy the cordova.js file for the proper platform iOS, Android etc. to your remote server deployment folder.
  4. If your using Cordova 3.0 or higher you will also need to copy any plugin JavaScript files to your remote server
  5. Add a script link in your remote app index.html file for cordova.js. The script link should occur before the Sencha microloader code.

When this is configured properly. Your Phonegap app will load the remote web app, run the cordova.js script then launch the Sencha app code. You will have access to the Phonegap device API from your remote app code.

I have used this approach with Sencha Touch 2.3.1 and Phonegap 3.5

You can also configure the appcache to allow your remotely served app to be available 'offline'

This was my grand question and I've spent ~3 days searching for answer.

My situation was similar: I have hybrid Cordova app with android plugins and I need to load all the web app scripts/content from remote server and at the same time I need to have access to plugins and native features.

In my case, I have to platforms: Android and Desktop PC to be able to access the same web app.

For Android platform, you have to copy all the files (cordova.js, cordova_plugins.js plugins*) from "platforms\android\assets\www\" to your server's web app root folder. You have to put them info platform specific folder on server (e.g. "js-android"). For me this step was a major show-stopper for native plugins to get working.

Somewhere in Cordova docs it is told that during prepare/build time different cordova.js is generated for every platform. Thant means, you have to implement extra function to detect platform and load correct cordova.js from server side.

In your web app you have to include only cordova.js (no need to include something regarding plugins to work).

It is trying to check the onDeviceReady event for window.cordova, which is why the error is popping up in the browser.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!