Firemonkey,位置传感器在iOS上的后台工作

问题描述 投票:1回答:1

我喜欢在后台模式下制作可以在iPhone上捕捉我的位置的应用程序,但我有一个问题:

申请不能要求表格许可requestAlwaysAuthorization。 基于这篇文章http://delphiworlds.com/2016/02/location-sensor-work-in-the-background-on-ios-9/(演示应用程序也不要求)如果我在System.iOS.SensorsTiOSLocationSensor.DoStart: Boolean;FLocater.requestWhenInUseAuthorization更改为FLocater.requestAlwaysAuthorization然后App不要求任何权限。

当我允许FLocater.requestWhenInUseAuthorizationFLocater.setAllowsBackgroundLocationUpdates(True);然后应用程序捕获位置最小化但在StatusBar中显示关于使用LocationSensor的大蓝色通知

但我需要以隐藏模式运行应用程序,我认为问题在于授权,但不知道如何解决。 (德尔福10.2.2)

我将不胜感激任何帮助

ios delphi location firemonkey
1个回答
4
投票

您只能使用showsbackgroundlocationindicator属性在iOS 11或更高版本中执行此操作:

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

为了使用它,您需要按照与原始文章类似的方法,重新声明CLLocation管理器,添加方法:

procedure setShowsBackgroundLocationIndicator(showsBackgroundLocationIndicator: Boolean); cdecl;

..还重新声明CLLocationManager委托。在TiOSLocationSensor.DoStart中,您可以检查iOS 11并设置属性,例如:

// Turn off the annoying blue indicator
if TOSVersion.Check(11) then
  FLocater.setShowsBackgroundLocationIndicator(False);
© www.soinside.com 2019 - 2024. All rights reserved.