REST API with screen locked

How can I use REST API to send GPS location data with the cell phone screen locked?

there was a similar question, from what i remember, its not possible to get location when the app is not in use

its not possible to get location when the app is not in use

This is correct, due to security regulations enforced by Android and IOS it is not possible to get location while the app is not in use. This can be seen with any other app nowadays, whereas it only allows you to share the location ‘While using the app’.

I just need to be able to continue using the GPS with the cell phone screen locked. is there no way to do it? If not, the GPS is useless.

There is a solid security-related reason why Android prohibits running an app while the phone is locked. So there is nothing on our part that we could do to make that possible. We understand the frustration, but nowadays, even using maps requires you to have your screen open all the time.

so, how do Waze or the OwnTracks apps on GitHub work?