Updating collections when cordova app is in background

Hi,

I’m using pmwisdom’s background location package for cordova to keep a background process open when the app is put into background mode. However I’m not able to update any data on the server from this background process. Neither updating the collection locally and having it sync or calling a Meteor method will allow me to update the collection on the server. I assume this is because the connection to the server is dropped when the app is put into the background and only the location service is running. Is there a way I can take the location update and send it to the server? Do I need to set up a rest api for this?

Many Thanks

1 Like

Same issue explained in this video: https://vimeo.com/182377692. No issue with Android, only iOS.
We are using: mirrorcell:background-geolocation-plus.
There are 4 status:

  1. foreground - device running
  2. foreground - device locked
  3. background - device running
  4. background - device locked
    The fourth status is where web socket connection is dropped till app is in foreground status again.
    I’ve opened an issue on mirrorcell:background-geolocation-plus GitHub account.
    Another plug-in (not running at this moment) zero asterisk:cordova-geolocation-background is based on rest operation and was able to contact the server and pass updated data. Here we have a disconnect and not reconnect probably due to a not authorized upgrade from HTTP to WebSocket connection. There is another strange thing: on iOS WKWebView use a local WebServer to avoid direct access to file system (Safari sandbox). When Cordova goes in background web server is stopped. It’s odd to note that if the app was in foreground status before lock connection is not dropped, and if it’s dropped (after 30 second of “no-ping” from client), then Meteor can reconnect. Instead if app is in background and device is locked, connection is dropped suddenly and Meteor can’t reconnect successfully. If you try, you’ll see “disconnected” or “connecting”, but never “connected” (from Debugger using Meteor.status())