LiveReload plugin for Cordova/PhoneGap applications. Watch the video demo.
Note: if you use the grunt-gapreload task, skip these steps and follow the proper documentation instead.
- Install the LiveReload app (latest version can be found here).
- Install the Apache Cordova 3 CLI:
$ npm install -g cordova
(you may need to usesudo
). cd
into your Cordova app folder previously created using thecordova create
command.- Install GapReload:
$ cordova plugin add pro.fing.cordova.gapreload --variable SERVER_HOST="<host>"
where<host>
typically is your localhost IP address (static is better). - Follow GapReload instructions in your terminal window and you will be good to go.
The SERVER_HOST
variable is mandatory. Other available variables are:
Variable name | Default value |
---|---|
SERVER_PORT | 8000 |
LIVERELOAD_HOST | SERVER_HOST |
LIVERELOAD_PORT | 35729 |
Generally you should not modify those values but, if you really have to, just know that you can.
Setting values for SERVER_HOST
and LIVRELOAD_HOST
using the CLI will also automagically whitelist them for you.
But you can also declare/override values in plugins/pro.fing.cordova.gapreload/gapreload.xml like so:
<?xml version="1.0" encoding="UTF-8"?>
<gapreload>
<param name="SERVER_HOST" value="whatever you want"/>
<param name="SERVER_PORT" value="whatever you want"/>
<param name="LIVERELOAD_HOST" value="whatever you want"/>
<param name="LIVERELOAD_PORT" value="whatever you want"/>
</gapreload>
Note: if you use the grunt-gapreload task, skip these steps and follow the proper documentation instead.
Because you shouldn't let this plugin make it to production.
cd
into your Cordova app folder.- Execute
$ cordova plugin remove pro.fing.cordova.gapreload
. - That's it, GapReload is gone for good.
- As GapReload will redirect your whole app to http://$SERVER_HOST:$SERVER_PORT/, cross-origin requests won't work anymore without a proper configuration.
- Test on platforms other than iOS and Android and make it work if needed.
- I noticed that when using Chrome 32.0.1700.107 and LiveReload 2.3.34, once every two page refresh, the livereload.js file doesn't load at all. An error is thrown and this is what I get for this particular request in the developer tools: caution provisional headers are shown...