capacitor-community / background-geolocation

A Capacitor plugin that sends you geolocation updates, even while the app is in the background.
MIT License
180 stars 56 forks source link

No locations sent when app is closed #19

Closed lucaoliano closed 3 years ago

lucaoliano commented 3 years ago

Describe the bug I'm developing an app that requires to push locations to BE even if the app has been closed, not simply put in background. I did several tests but I was not able to do this, the app it stops to send location when I close it. Is this the normal behavior, is it a bug or am I doing something wrong?

To Reproduce Steps to reproduce the behavior:

  1. close the app

Expected behavior The BE continue to receive locations even if the app has been closed, not in background

Smartphone (please complete the following information):

diachedelic commented 3 years ago

Hi @lucaoliano . I'm afraid that closing the app will indeed stop location updates. There may be a way to implement this for Android using services, but I am fairly certain this would never be possible on iOS.

lucaoliano commented 3 years ago

@diachedelic thank you for the quick response. In the past I used this Cordova plugin and locations were sent with closed app both for iOS and Android

diachedelic commented 3 years ago

That's interesting, I did not know iOS supported that kind of background work. Communicating to a server is out of scope for this plugin. I actually wrote this plugin because I felt mauron85's plugin (which I used for two years) was too big and complex. Does mauron85's plugin no longer work for you?

lucaoliano commented 3 years ago

I have an old app based on the 2.x version of mauron85's plugin and it works fine. Currently I'm rewriting the app, so I tried the 3.x version and I'm not able to send location with closed app, so I tried your plugin and it is the same.

Next tests are:

I will let you know if any of this test have success.

lucaoliano commented 3 years ago

@diachedelic finally I found the mistake with mauron85's plugin v3.x, it started to send location with closed app after that I checked the Background processing capability in Xcode. I hope that this can help with development of your plugin, I I'd rather use your plugin since it hasn't unneeded complexity and is a native capacitor plugin.

diachedelic commented 3 years ago

I'm glad you got it working. My vision for this plugin is to provide a simple, lightweight alternative to the more feature rich plugins such as mauron85 and cordova-background-geolocation-lt. If those plugins cease to function with Capacitor I will consider incorporating such features.

csotiMatyas commented 1 year ago

@lucaoliano Hey, what was the issue with the mauron85's plugin v3.x, and how di d you solve it. And was it working with to?

brandonporcel commented 4 months ago

does anyone have a example code with ionic angular? didnt work for me

satheshsat commented 2 months ago

Got same issue on android 14. background location not sending after app is closed. Notification also removed.

csotiMatyas commented 2 months ago

@satheshsat the plugin doesnt work when the app is closed. What we ended up using is: transistorsoft background geolocation. Its payed plugin for android. But its the best documented plugin i have ever seen, if its of any value.