NSLocationWhenInUseUsageDescription 警告,但我已经添加了它

NSLocationWhenInUseUsageDescription warning, but I have already added it

虽然我已经添加了:

NSLocationWhenInUseUsageDescription

我不断收到此警告:

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。不知道该怎么做。

我在

请求授权

viewDidLoad

如下:

self.locationManager.requestWhenInUseAuthorization()

当我删除这一行时,错误消失了。

两者相加

NSLocationAlwaysAndWhenInUseUsageDescription

NSLocationWhenInUseUsageDescription

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>

从 plist 和 运行 应用程序中删除 NSLocationWhenInUseUsageDescription 并再次添加并再次 运行 应用程序

有大量结构不良的框架(即 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. Do be sure to check audit trail for the location queries on ios 15 or later.</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 foo@bar.baz</string>

否则,在传达确切用法和风险的措辞中要狡猾,让应用程序访问其沙箱之外的任何内容,并在审计跟踪中教育您的用户以获得必须不时检查的给定权限(就像任何人都会那样做)。值得庆幸的是,最近(大约 ios14),Apple 向最终用户报告可疑 activity,例如 MapsMe 一直在后台跟踪。

嗯,实际上,在我的例子中,我需要像这样放置所有三个:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>...</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>...</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>...</string>

否则,我不会收到要求允许位置的弹出警报。

注意:我是用Flutter开发的,不知道对这种情况有没有影响...