MAUI SecureStorage“添加记录时出错:MissingEntitlement”

问题描述 投票:0回答:1

我正在使用 MAUI 开发窗口,并且正在为 android 和 ios 平台构建。 以下代码在 Android 上运行良好,但在 ios 上出现错误“添加记录时出错:MissingEntitlement”

await SecureStorage.SetAsync("access_token", userAccount.token);

我正在使用从 Mac 连接的 ios 模拟器。 在 Platforms/iOS/Info.plist 中,我添加了这些代码

<key>keychain-access-groups</key>
<array>
    <string>$(AppIdentifierPrefix)com.[my app id here]</string>
</array>

有办法解决吗?

maui
1个回答
0
投票

要在 iOS 上使用

SecureStorage
API,您需要在 Apple 配置文件中为您的应用程序启用正确的权利。

这也在 Microsoft Docs 中进行了描述。

在 iOS 模拟器上开发时,启用 Keychain 授权并为应用程序的捆绑包标识符添加 Keychain 访问组。

在项目中创建或打开Entitlements.plist,找到Keychain授权并启用它。这将自动将应用程序的标识符添加为一个组。有关编辑 Entitlements.plist 文件的更多信息,请参阅 Entitlements

在项目属性中,在 iOS Bundle Signing 下将自定义权利设置为 Entitlements.plist。

还列出了附加提示:

部署到 iOS 设备时,不需要此权利,应将其删除。

© www.soinside.com 2019 - 2024. All rights reserved.