简体   繁体   English

当mapView执行时,要求用户使用iOS访问其位置的权限

[英]Asking user permission for accessing their location with iOS when mapView does

I've developed an app using a MapView - when the app starts up, it asks the user to allow their location to be accessed/used without any coding from me. 我使用MapView开发了一个应用程序 - 当应用程序启动时,它要求用户允许访问/使用它们的位置,而无需我编码。 Is this sufficient for permission or should I also specifically ask the user and provide a reason for the access? 这是否足以获得许可,还是我还应该特别询问用户并提供访问的原因? Will Apple reject the app on submission if I don't specifically make the request and allow the MapView to request this on my behalf? 如果我没有专门提出请求并允许MapView代表我提出请求,Apple会拒绝提交的应用程序吗?

You don't need to ask the user for permission, iOS does it for you automatically. 您无需向用户请求权限,iOS会自动为您执行此操作。

You should set the purpose string property in the CLLocationManager object so that when the system asks it can also tell the user why you want their location. 您应该在CLLocationManager对象中设置目的字符串属性,以便在系统询问时也可以告诉用户您希望其位置的原因。

locationManager.purpose = @"Location needed to show zombies that are nearby.";

Set this property before calling startUpdatingLocation so that it gets shown to the user in the system alert that asks for permission to use location. 调用startUpdatingLocation 之前设置此属性以便在系统警报中向用户显示该属性,该警报要求使用位置的权限。

In the delegate you can implement the method locationManager:didChangeAuthorizationStatus: to know whether the user allowed core location or not. 在委托中,您可以实现方法locationManager:didChangeAuthorizationStatus:以了解用户是否允许核心位置。

As of iOS 6, the correct place for the "purpose" message is in the Info plist file. 从iOS 6开始,“目的”消息的正确位置在Info plist文件中。

The NSLocationUsageDescription property should be set with the message to display to users 应设置NSLocationUsageDescription属性,并显示要显示给用户的消息

Apple provides good documentation: https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html Apple提供了很好的文档: https//developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

You don't need to tell the user why their location is being accessed especially if the application is based on location and mapping. 您无需告知用户为何要访问其位置,尤其是在应用程序基于位置和映射的情况下。 With that said it is nice to tell the user what exactly you will do with their data before the permission popup comes up so that hopefully more users will accept. 有了这个说,很高兴告诉用户在权限弹出窗口出现之前你将如何处理他们的数据,以便更多用户可以接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM