要在iOS中删除后台位置提醒? [英] Removing the background location alerts in iOS?

查看:93
本文介绍了要在iOS中删除后台位置提醒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个跟踪用户位置的导航应用.

I'm writing a navigation app that tracks the user location.

为了继续显示有关路线的通知(电话被锁定,接听电话等)-我还需要在应用程序处于后台时继续跟踪位置:(Capabilities>Background Modes>Location updates, locationManager.allowsBackgroundLocationUpdates = true)

In order to continue showing notification about the route (when phone is locked, answering the phone, etc.) - i also need to continue tracking the location while the app is in the background: (Capabilities>Background Modes>Location updates, locationManager.allowsBackgroundLocationUpdates = true)

很长一段时间以来,我一直在努力解决这个问题,并且阅读了很多有关该问题的信息,但是找不到我想要的答案. 我已经实现了这两种选择:

I have been struggling with this question for a very long time and read a lot about it, but couldn't find the answer i'm looking for. i have implemented both options :

(locationManager.requestWhenInUseAuthorization()):

每当应用程序在后台运行时,每个应用程序顶部都会有一个额外的蓝色位置警报栏.

Whenever the application is in the background there is the additional blue location alert bar on top of every application.

  1. 是否可以删除此横幅?还是只能在很短的时间内得到它?再次-我 无法使用locationManager.stopUpdatingLocation()-因为我需要 它们在后台.
  1. Is there a way to remove this banner? or get it only for a really short period of time? again - i cannot use locationManager.stopUpdatingLocation() - since i need them in the background.

选项2-始终请求(locationManager.requestAlwaysAuthorization()):

一段时间后,我的用户收到了可怕的后台位置提示消息.示例:

Option 2 - Request Always (locationManager.requestAlwaysAuthorization()):

After a while my users get the background location frightening prompt message. Example:

"APP"已在后台使用您的位置.你想要_____吗 继续允许吗?

‘APP' has been using your location in the background. Do you want to continue allowing this?

  1. 是否可以删除此消息? (以位智为例-相同 权限,但我很确定我从未收到过这样的消息)
  2. 仅在以下情况下,我才能停止在后台中获取位置更新吗? 应用程序终止了吗?,并且避免唤醒应用程序(我实际上不想要这些位置)吗?我试图用 locationManager.stopUpdatingLocation()终止应用程序时- applicationWillTerminate(_ application: UIApplication)
  1. is there a way to remove this message? (looked at Waze as an example - same permissions but i'm pretty sure that i never got such a message)
  2. can i stop getting location updates in the background only when the app is terminated? and avoid the app being awakened (i actually don’t want these locations)? i tried to use the locationManager.stopUpdatingLocation() when terminating the app - on applicationWillTerminate(_ application: UIApplication)

似乎两者都不仅是不良的UX,会阻碍用户的积极性,而且在其他基于位置的应用程序中也很罕见.

Seems that both are not only bad UX that can discourage users, but also very uncommon in other location based apps.

我无法弄清楚我在这里想念什么.

I cannot figure out what i'm missing here.

推荐答案

您提到的两种机制均已由操作系统采用,以保护用户.他们不仅在警告用户该应用程序正在后台检索其位置,而且还警告某些东西在不再需要时会消耗电池电量.

Both mechanisms you mentioned are in place by the OS in order to protect users. They are not only alerting the user that an application in on the background retrieving its location, but also that something might be consuming battery when not needed anymore.

无法避免这种情况,因此您应该根据应用程序的需求来决定哪个最合适.

There's no way to avoid this, so you should decide which one fits best according to the needs of your application.

例如,某些应用提供路线指示,这些应用往往在顶部带有蓝色横幅(请参见 Google Maps 甚至Apple Maps.

For instance, some apps give directions about a route, these apps tend to have the blue banner at the top (see Google Maps or even Apple Maps).

另一方面,其他一些应用程序则有兴趣随时获取位置更新(例如健身应用程序或跟踪您所有运动的应用程序,请参见

On the other hand, some other apps are interested in getting location updates at all times (e.g. fitness apps or apps that track all your movement, see Moves). In this situation the user will be alerted once about the fact that this app is continuously using its location on the background, if they accept it they won't be bothered again (iOS 8 and above).

以下是Apple员工有关选项2的一些信息:

Here's some info regarding option 2 from Apple staff:

应用获得始终"授权并开始在后台使用位置服务后几天,系统将要求用户再次确认他们仍然希望该应用在后台跟踪其位置.

A few days after the app obtains the "always" authorization and starts using location services in the background, the user will be asked to confirm once again that they still want this app to track their location in the background.

如果应用正在后台获取用户的位置,则无法采取开发人员操作来避免此确认.

There is no developer action that can be taken to avoid this confirmation if the app is obtaining users' location in the background.

来源:Apple论坛

>来源:关于iOS 8和更高版本中的隐私和位置服务

Source: About privacy and Location Services in iOS 8 and later

这篇关于要在iOS中删除后台位置提醒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆