await SecureStorage.GetAsync( "Key" );返回空值



描述

await SecureStorage.GetAsync("Key"); returns null for Android OS.

SecureStorage在Xamarin表单项目中的其他地方都有效。

如果我将值存储在IFunction2>gt;调用&试着取回它。值未保留在MainActivity中>gt;OnCreate也是。

复制步骤

再现1

  • 在MyFirebaseMessagingService(firebase服务(中存储令牌>gt;OnNewToken
  • 尝试在调用库IFunction2>中检索令牌>调用
  • 返回null

再现2

  • 在主活动中存储一些字符串>gt;创建时
  • 尝试在第二次运行中检索它
  • 返回null

预期行为:字符串应持久化

实际行为:空结果

Basic Information
Version with issue: 1.5.3.2
Last known good version: not known
IDE: VS for mac
Platform Target Frameworks:
Android: 10
Nuget Packages: Xamarin.Essentials
Affected Devices: nova 3i

记得添加:

<manifest ... >
...
<application android:allowBackup="false" ... >
...
</application>
</manifest>

并且您可以始终使用默认值(以防万一(

await SecureStorage.SetAsync("oauth_token", "secret-oauth-token-value");

更多文档位于:https://learn.microsoft.com/en-us/xamarin/essentials/secure-storage?tabs=android

最新更新