-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background geolocation stops working after 5 minutes when the application is in the Background or Screen is locked #276
Comments
Sounds like a case for |
Hello @christocracy !! Thank you for the reply. The issue is still there. Also, we were already using useLegacyBridge:true in our application. Here are some other piece of code to refer: I hope they help in deducing the issue because I'm not able to since past few days. capacitor.config.json: const config: CapacitorConfig = { } }; export default config; **ionic.config.json: ** { "name": "io.ionic.starter", "integrations": { "capacitor": {} }, "type": "angular" } strings.xml: MY APP NAME MY APL NAME> io.ionic.starter io.ionic.starter app.component.ts: private initializeBackgroundListener() { disableWebView() { enableWebView() { package.json: "name": "io.ionic.starter", "version": "0.0.1", }, |
This is a Capacitor problem. The plug-in did its job firing those events. If Capacitor is failing to do its job, queueing those events instead of firing them immediately, that’s up to Capacitor to fix |
Hello @christocracy |
Hi @MehulGosar, Thanks for posting this. Did you find a solution for your issue? I’m experiencing the same problem with the Currently, I retrieve all location data at the end of the activity using the let locations = await BackgroundGeolocation.getLocations(); While this works, it’s not perfect. It seems that under certain conditions the SQLite database used by the plugin may get cleared, resulting in missing location data. @christocracy , do you have any recommendations or best practices to ensure the reliability of location data persistence when the app is in the background? Thanks, |
The only reason the plug-in deletes a record from its SQLite db is it your server returns HTTP status 200.
The plug-in has no issues with data reliability. |
@chrisbiscuit and @christocracy I found a solution, and I'm testing it out. It's not a solution per se, but an amalgam of various things I tried to make it work. And it did. |
So are saying that after 5 minutes, it keeps recording the same last known location (location at the 5 minute mark) to the database, over and over? Then when the app is forgrounded, it takes all of those repeated locations and sends the requests? Or are you saying that after 5 minutes, it queues up a bunch of blank/pending requests, and then when the app is forgrounded - it fills in all those requests with the devices current location and sends them? in either case - what interval does this happen? Like in scenario A, after 5 minutes does it record the duplicate location to the DB every x seconds? or in scenario B, how what is the interval between the requests that get set up pending ? |
Does the plug-in continue to operate, witnessed by the debug sound FX? |
Your Environment
Plugin version:
For capacitor background geolocation: 4.10.0 and for background fetch 1.0.4
Platform: iOS or Android
Platform is Android
Device OS version:
For Redmi K50: 1.0.2.0.ULOINXM (Android 14)
For One Plus Nord CE2: : OxygenOS 14.0 (Android 14)
For Motorola Moto G52L Software channel Retin (Android 13)
Device manufacturer / model:
Tested on Redmi K50
Tested on One Plus Nord CE2
Tested on Motorola Moto G52
XCode version:
NA as Windows been used
Capacitor info (
npx cap doctor
)Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2.
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 4.5.0
@capacitor/android: 4.3.0
@capacitor/core: 4.3.0
[success] Android looking great!
Plugin config provided to
#ready
:INSERT_YOUR_CODE_HERE
**************************** app.component.ts ***************************
Expected Behavior
Whenever a user logs into the application, we capture their user ID and store it locally in our Sqlite database or local storage on the phone. Now, whenever the user uses our application, whether in the foreground or background, we want to capture the user's location and post it on our server along with the timestamp and the UserID. The unique identifier between the users is the User ID.
Note 1: Storing in local Sqlite storage helps us retrieve the user Id even when the user has logged out of the application but still has the application in the background or when the screen is locked.
Note 2: Capture the user’s location in foreground and background irrespective of the phone’s screen been locked or not
Actual Behavior
We can capture the user’s location when the application is in the foreground irrespective of whether the phone’s screen has been locked or unlocked. But:
As soon as the application goes to the background following behaviour is observed. Irrespective of the order of occurrence of the below scenarios, the application can capture the user’s location for a maximum of 5 minutes:
Steps to Reproduce
Context
Note: I have used the Flutter application from the Play Store. It tick marks all our requirements. But we can't replicate the same in our application after more than a month of multiple attempts and referring documentation.
We want to capture the user’s location whenever the user is moving having the application is been used irrespective of it is in foreground or background and the screen been locked or unlocked
Debug logs
Logs
<!—No Logs to share -->
The text was updated successfully, but these errors were encountered: