alejandro.sawers 11 Posted August 20 (edited) While this could frustrate some users, the truth is that approximate location access is not suited for most geolocation applications/features. Now if the user has given a incorrect location level access to the app (probably by mistake) it should inform the user so the permission level is corrected before accessing the features. Now for Delphi FMX apps this is trivial in Android as there are two separate permissions for approximate and precise location access and a simple query helps to determine the access level granted. The culprit is iOS, as since iOS 14 the accuracy authorization level is separated from the location authorization status itself, and apparently there is no way to access such value from user code (accuracyAuthorization is a CLLocationManager instance property but such instance is buried on the implementation section of System.iOS.Sensors.pas). So before patching this file and fighting the compiler about dependent units "compiled with another version of...", all without knowing if this would work at the end, I would like to know if somebody found another way to achieve this. Edited August 20 by alejandro.sawers Share this post Link to post
Dave Nottage 557 Posted August 20 3 hours ago, alejandro.sawers said: I would like to know if somebody found another way to achieve this. You can achieve this by writing code that uses CLLocationManager. Create an instance of it, and examine the value of accuracyAuthorization. If it is CLAccuracyAuthorizationReducedAccuracy and your app needs full accuracy, inform the user to: Go to Settings > Privacy & Security > Location Services. Select your app Toggle the Precise Location switch on Example code: uses iOSapi.CoreLocation; procedure TForm1.Button1Click(Sender: TObject); var LManager: CLLocationManager; begin LManager := TCLLocationManager.Create; if LManager.accuracyAuthorization = CLAccuracyAuthorizationReducedAccuracy then // Inform the user end; 1 Share this post Link to post
alejandro.sawers 11 Posted August 21 Thanks Dave, this works like a charm and without patching anything. Hope Embarcadero adds an attribute/function to TLocationSensor (much like Authorized) to consolidate this. Share this post Link to post