Get User Authorization to ALWAYS Read Geolocation


When using TLocationSensor to get user geolocation on iOS, the default hard-coded requested authorization is only for when app is in use (app is foreground). However, iOS does allow you to require ALWAYS authorization from user, even when the app is in background or terminated, but I cannot request this mode with firemonkey.

In System.iOS.Sensors.pas, in the function TiOSLocationSensor.DoStart : Boolean ; is written FLocater.requestWhenInUseAuthorization;.

I tried to copy this file to my project’s folder and change this line to FLocater.requestAlwaysAuthorization;, but no luck… Maybe because it is RTL?

Anyone knows how to solve this and request user authorization to get location even when on background?

Apple docs (for reference only):

Comments are closed.