Reputation: 125
Does anyone know how to serve the phonegap/cordova app www folder remotely?
So i'm developing this camera app using the sencha touch framework with a layer of cordova to gain access to devices native camera.
Im trying to serve the www folder remotely to be able to push updates to users without having to update the app.
So i have tried to just copy the www folder from the android platform to the remote server. This worked on android but all other devices failed to load the website. Is the www folder specific to the device?
When i test on ios i get a JS alert displaying "gap_init:2"
EDIT: As it turns out, android was caching the old website. Now i'm down to nothing working.
Any help would be appriciated.
Upvotes: 1
Views: 5086
Reputation: 256
It is trying to check the onDeviceReady event for window.cordova, which is why the error is popping up in the browser.
Upvotes: 0
Reputation: 47
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).
Upvotes: 1
Reputation: 560
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.
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'
Upvotes: 0