2017-01-16 45 views
5

我目前用在这里找到了Xamarin地理位置插件死亡:Xamarin的iOS Geolocator后台服务后约30分钟

https://github.com/jamesmontemagno/GeolocatorPlugin

要在应用程序执行的定位服务,我使用Xamarin形式(PCL)建设。 我相信我已经在相关权限设置中添加了这个功能。

当应用程序处于活动状态并锁定时(但前景应用程序),GPS工作良好。然而,当通过点击“主页”按钮将应用推到iOS上的背景时,它仍然会跟踪用户并突出显示“应用正在使用你的位置”消息,但是在30秒之后的一段时间之后, 40分钟,此消息消失,并且GPS似乎停止跟踪用户,直到他们将应用程序带回前台。

一旦应用程序被带到前台,它可以再次后台再次30-40分钟重复周期。

我已经确保了定位对象允许后台更新:

public static Plugin.Geolocator.Abstractions.IGeolocator locator; 
locator = CrossGeolocator.Current; 
locator.AllowsBackgroundUpdates = true; 
locator.DesiredAccuracy = 20; 

.PausesLocationUpdatesAutomatically调用显示,这是假的(我认为是默认值)。

编辑

我有以下关键的Info.plist:

NSLocationWhenInUseUsageDescription 
NSLocationAlwaysUsageDescription 

并启用背景更新位置:

enter image description here

enter image description here

但是我没有启用Girish在答案中的背景提取,这是我需要做的事吗?

+0

您添加了哪些权限以及在哪里? – Demitrian

+0

请参阅我的编辑,谢谢! – Aphire

回答

0

请检查您是否启用了位置更新的后台模式。

enter image description here

+0

我已启用位置更新和背景模式,我没有启用后台抓取或远程通知,请参阅我的编辑 – Aphire