1

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

Andy
  • 114
  • 2
  • 13
  • 1
    You can't hide that blue effect it's by ios to inform the user that there are apps that use location updates capability – Shehata Gamal Jan 05 '18 at 00:41

1 Answers1

4

You can do this only in iOS 11 or greater by using the showsbackgroundlocationindicator property:

https://developer.apple.com/documentation/corelocation/cllocationmanager/2923541-showsbackgroundlocationindicator

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);
Dave Nottage
  • 3,411
  • 1
  • 20
  • 57
  • 1
    Edited: Works fine only dont forget to do this https://stackoverflow.com/questions/44424092/location-services-not-working-in-ios-11 – Andy Jan 05 '18 at 13:39