Well, I use firebase to get the positions in real time and they work, every time I open the app it gives me the current position and the last position of when the app closes, that is, I close the app and that is the last position and when I open it shows me the last one and where it is in real time that I do with firebase, if what you want is to continue running after closing the app what you should do is make a service and then if you want to add a notification that the position that person has changed so that the user enters through the notification to the app, the same can also be done with firebase I do all this and the position is every 1sec
I hope I have helped you, and the next one is more explicit or put some code to see what you mean clearly, have a good day or night xD