capacitor-community / capacitor-community/background-geolocation
[Feature] Allow "off-route" notification
- Dominant language
- Java
- Stars
- 249
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
When a user is following a route and would like to get notified when stepping away from it, even though the app is in the background (phone is locked in the pocket or even using a different app right now).
**Describe the solution you'd like**
I thought about the following possible solutions:
1. Add to the API the ability to "set a route" by sending a list of coordinates to the plugin.
2. Once these are sent, the plugin can play a sound every time a location is received and the position is far enough from the current location. In terms of code changes, this shouldn't be a complicated task (I have it in my code in javascript right now)
Another solution would be with a smaller API foot print by saying "play sound" which will work in the background.
**Describe alternatives you've considered**
I've tried to implement it with `@capgo/native-audio` the problem is that after 5 minutes in the background the sound stops playing.
When reading what might cause this, it seems that (at least in Android) there's a need to run this in a service and not in the "regular app" code.
If this is done in a different plugin, I believe there will be a need to create another foreground service and thus show another icon to the user, which is not a great user experience, which I would like to avoid
**Additional context**
This feature has been on my mind for a long time and due to the complexity of the other plugin I never got around to implementing it.
It is in my app, only when the app is topmost, so I have all the code relevant to it, but the limitation of it to only run when the app is topmost makes this feature almost useless...
Now that the code here is simple enough, it's a lot easier to consider this.
I know it might complicate things a bit and I'm not sure it fully belongs here, but I'd be happy to know what you think.
Contributor guide
Assessment
This issue has not been assessed yet.