floatinghotpot / cordova-httpd

Embed tiny web server into Cordova with a plugin
285 stars 148 forks source link

Background mode #7

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi,

The server stops working (is paused) when the app is put in background mode (switching to another app).

Is it possible to have it running when the app is paused?

Thanks,

Michael

floatinghotpot commented 9 years ago

try this background plugin, it will prevent app from pause:

https://github.com/katzer/cordova-plugin-background-mode

ghost commented 9 years ago

Thanks. It worked.

Here is what I have done:

config.xml

    <gap:plugin name="de.appplant.cordova.plugin.background-mode" />
    <gap:config-file platform="ios" parent="NSLocationAlwaysUsageDescription" overwrite="false"> 
      <array> 
        <string>Enable file sharing (allow local server to run in background)</string> 
      </array> 
    </gap:config-file>     

javascript

      navigator.geolocation.getCurrentPosition(function(){ /* to trigger location prompt */
        window.plugin.backgroundMode.enable(); /* enable background mode */
      });