Search code examples
cordovasencha-touch

serving cordova app www folder remotely


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.


Solution

  • 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'