I like to make application that can catch my location on iPhone in background mode, but i have a problem:
Application cant ask form permission requestAlwaysAuthorization
.
Based on this article http://delphiworlds.com/2016/02/location-sensor-work-in-the-background-on-ios-9/ (demo application not ask too) if I make changes in System.iOS.Sensors
in TiOSLocationSensor.DoStart: Boolean;
from FLocater.requestWhenInUseAuthorization
to FLocater.requestAlwaysAuthorization
then App not asking for any permissions.
When I allow FLocater.requestWhenInUseAuthorization
and FLocater.setAllowsBackgroundLocationUpdates(True);
then application catch location when minimized but show big blue notification in StatusBar about using LocationSensor
But I need to run application in hidden mode, I think that problem is in authorisation but dont know how to solve. (Delphi 10.2.2)
I will be grateful for any help
You can do this only in iOS 11 or greater by using the showsbackgroundlocationindicator property:
In order to use it, you'd need to follow a similar approach to the original article, redeclaring CLLocation manager, adding the method:
procedure setShowsBackgroundLocationIndicator(showsBackgroundLocationIndicator: Boolean); cdecl;
..and also redeclare CLLocationManager delegate. In TiOSLocationSensor.DoStart, you could check for iOS 11 and set the property, e.g:
// Turn off the annoying blue indicator
if TOSVersion.Check(11) then
FLocater.setShowsBackgroundLocationIndicator(False);