ios NSLocationWhenInUseUsageDescription 警告,但我已经添加了它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46193797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NSLocationWhenInUseUsageDescription warning but i have already added it
提问by Mohamed
While I have already added:
虽然我已经添加了:
NSLocationWhenInUseUsageDescription
NSLocationWhenInUseUsageDescription
I keep receiving this warning:
我不断收到此警告:
This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSLocationWhenInUseUsageDescription key with a string value explaining to the user how the app uses this data
此应用程序试图在没有使用说明的情况下访问隐私敏感数据。应用程序的 Info.plist 必须包含一个 NSLocationWhenInUseUsageDescription 键和一个字符串值,向用户解释应用程序如何使用这些数据
FYI: I have multiple Info.plist in the app. Not sure what to do.
仅供参考:我在应用程序中有多个 Info.plist。不知道该怎么办。
采纳答案by Mohamed
I was requesting authorisation in
我在请求授权
viewDidLoad
查看已加载
as follows:
如下:
self.locationManager.requestWhenInUseAuthorization()
when I removed this line the error disappeared.
当我删除这一行时,错误消失了。
回答by Kartihkraj Duraisamy
Adding both
两者相加
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
and
和
NSLocationWhenInUseUsageDescription
NSLocationWhenInUseUsageDescription
keys in plist solved my problem.
plist 中的键解决了我的问题。
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location is required for xyz benefits for you</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is required for xyz benefits for you</string>
回答by Anton Tropashko
There are a ton of poorly structured frameworks (namely FirebaseMessaging) that use camera and location for no benefit to the user. You should alert end user this functionality is NOT needed for your application and user must NOT grant app access to that parasite inside. What a sad, sad times we live in.
有大量结构不佳的框架(即 FirebaseMessaging)使用相机和位置对用户没有任何好处。您应该提醒最终用户您的应用程序不需要此功能,并且用户不得授予应用程序访问该寄生虫内部的权限。我们生活在多么悲伤、多么悲伤的时代。
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location is not needed. This request has popped up due to a 3rd party framework used by the app in a context that does NOT need you to reveal you location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>You will get zero benefit allowing this app accessing your location. You should never see this alert. If you do alert technical support at [email protected]</string>
回答by Tomas Baran
Well, actually, in my case I needed to put ALL THREE of them like this:
嗯,实际上,在我的情况下,我需要像这样放置所有三个:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>...</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>...</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>...</string>
Otherwise, I wouldn't get the pop-up alert asking to allow the Location.
Note: I develop in Flutter, I don't know if it has any repercussions in this case...
注:我是用Flutter开发的,不知道这种情况有没有影响……
回答by omkar marathe
remove the NSLocationWhenInUseUsageDescription from plist and run the application and add again and run the application again
从 plist 中删除 NSLocationWhenInUseUsageDescription 并运行应用程序并再次添加并再次运行应用程序