Run a Background Service every Xmins to get User's Location Firebase

I want to run a background service when the app is in the background or even closed=killed. So the service basically gets the current user’s location every 10mins, checks it with the previous location of the user, and if the distance between the last location and current location is more than 500m i want to send them a notification. How can I achieve this?
I am also using firebase for my backend. I read about push notifications from firebase, but I want to send notifications based on the user’s current location which would differ from user to user.
I’ve looked at all possible answers, but none of them meet my requirements.

Thank You in Advance!

This is big red flag in apps as it can lead to some real privacy concerns and a lot of questions from iOS and Android app store reviewers.

IF you need to do some background services, there is the background task API from capacitor.


Most of the plugins that I’m using are of Cordova. Is there a way to do this using cordova?