ios 什么是 NSFaceIDUsageDescription - Face ID 使用说明 Info.plist 键?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46309440/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:29:15  来源:igfitidea点击:

What is NSFaceIDUsageDescription - Face ID Usage Description Info.plist key?

iosxcodeios11xcode9face-id

提问by Steve Moser

There is a new privacy NSFaceIDUsageDescriptionInfo.plist key in the Xcode 9 GM where a developer supplies the usage description for the permissions alert. Does anyone have a link to docs on it? The plist view in Xcode summarizes it as:

NSFaceIDUsageDescriptionXcode 9 GM 中有一个新的隐私Info.plist 键,开发人员可以在其中提供权限警报的使用说明。有没有人有它的文档链接?Xcode 中的 plist 视图将其总结为:

Privacy - Face ID Usage Description

隐私 - 面容 ID 使用说明

回答by Michael Rourke

Now further explained in the above mentioned forum (by an Apple employee) https://forums.developer.apple.com/message/265156:

现在在上述论坛(由 Apple 员工)中进一步解释https://forums.developer.apple.com/message/265156

Face ID requires adding a usage string with the key NSFaceIDUsageDescription (aka Privacy - Face ID Usage Description) to your app's Info.plist.

In the simulator, the Face ID permissions alert will show "This app was designed to use Touch ID and may not fully support Face ID" if that key is missing. On an actual device, your app will crash the same as if any other required usage string is missing.

面容 ID 需要将带有密钥 NSFaceIDUsageDescription(又名隐私 - 面容 ID 使用说明)的用法字符串添加到您的应用程序的 Info.plist。

在模拟器中,如果缺少该密钥,Face ID 权限警报将显示“此应用程序旨在使用 Touch ID,可能不完全支持 Face ID”。在实际设备上,您的应用程序将崩溃,就像缺少任何其他必需的使用字符串一样。

回答by Krunal

Privacy - Face ID Usage Description (NSFaceIDUsageDescription) is string key, lets you describe the reason your app uses Face ID.

隐私 - 面容 ID 使用说明 (NSFaceIDUsageDescription) 是字符串键,可让您描述您的应用使用面容 ID 的原因。

To protect user privacy, an iOS app that links on or after iOS 11 and that would access Face ID if the hardware supports it, must statically declare the intent to do so. Include the NSFaceIDUsageDescriptionkey in your app's Info.plist file and provide a purpose string for this key. If your app attempts to access Face ID without a corresponding purpose string, your app may exit.

为了保护用户隐私,一个在 iOS 11 上或之后链接的 iOS 应用程序,如果硬件支持它,将访问 Face ID,必须静态声明这样做的意图。将NSFaceIDUsageDescription密钥包含在您应用的 Info.plist 文件中,并为此密钥提供一个用途字符串。如果您的应用尝试在没有相应用途字符串的情况下访问面容 ID,您的应用可能会退出。

Note: This key is supported in iOS 11 and later.

注意:iOS 11 及更高版本支持此键。

Face-Id authentication is introduced for/with iPhone-X device and will work with iPhone-X only (Even no simulator)

为 iPhone-X 设备引入了 Face-Id 身份验证,并且仅适用于 iPhone-X(即使没有模拟器)

With Xcode 9.0.1 & Xcode 9.2 beta - it seems found working

使用 Xcode 9.0.1 & Xcode 9.2 beta - 似乎可以正常工作

Ref. link to Apple Document - NSFaceIDUsageDescription
List of all available keys - Cocoa Keys

参考 链接到 Apple 文档 - NSFaceIDUsageDescription
所有可用密钥的列表 - Cocoa Keys

回答by Stefan Morcodeanu

maybe I'm later to the party but you can fix this just by adding this

也许我迟到了,但你可以通过添加这个来解决这个问题

<key>NSFaceIDUsageDescription</key>
<string>$(PRODUCT_NAME) Authentication with TouchId or FaceID</string>

to Project-Info.plist

Project-Info.plist

回答by whyoz

I have users that were reporting an app crash when the first TouchID alert shows. The fix was to test on the device and read the console (Xcode 9.4.1):

我有用户在第一个 TouchID 警报显示时报告应用程序崩溃。修复是在设备上测试并读取控制台(Xcode 9.4.1):

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSFaceIDUsageDescription key with a string value explaining to the user how the app uses this data.

此应用程序已崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据。应用程序的 Info.plist 必须包含一个 NSFaceIDUsageDescription 键和一个字符串值,向用户解释应用程序如何使用这些数据。

Simply adding NSFaceIDUsageDescriptionby right clicking and "Add Row" in the root of the Info.plist and pasted NSFaceIDUsageDescription in and set it to YES.

只需通过右键单击并在 Info.plist 的根目录中“添加行”来添加NSFaceIDUsageDescription并粘贴 NSFaceIDUsageDescription 并将其设置为 YES。

The simulator isn't going to support FaceID so apps that use logins, keychain, and TouchID are affected if you don't add a one liner to the plist to support FaceID verification. The user will get an alert asking them to allow FaceID to log into your app by default so no coding required to support FaceID if you're already setup for TouchID.

模拟器不支持 FaceID,因此如果您不向 plist 添加一行以支持 FaceID 验证,使用登录名、钥匙串和 TouchID 的应用程序会受到影响。用户将收到一条提醒,要求他们默认允许 FaceID 登录您的应用程序,因此如果您已经设置了 TouchID,则无需编写代码即可支持 FaceID。