If you really want to have it working on all devices, I suggest you this approach:
- Set up Firebase messaging
- Subscribe all devices to specific topic e.g. "UPDATE_LOCATION"
- Extend
FirebaseMessagingService
and implement onMessageReceive()
- If your data message contains instruction to update location, call the method to update location from
onMessageReceive()
- Trigger recurring messages to "UPDATE_LOCATION" topic from Firebase (CRON job or scheduled tasks)
It's a little more work that methods you have already tried, but it works on all phones and also after device restart and system update.
Additional plus is that you have control over the location updater from your backend (not per device which relies on app update).