react-native - 提供给 SecureStore 的密钥无效
问题描述
我收到以下错误
未处理的承诺拒绝:错误:提供给 SecureStore 的密钥无效。键不能为空,并且只能包含字母数字字符、“.”、“-”和“_”。
我的代码:
function onpresscard(item) {
const lang = item.code;
firebase
.firestore()
.collection(`mechphone`)
.add({
phonenumber: phonenumber,
})
.then((docRef) => {
const id = docRef.id;
const pid = phonenumber+'id';
const langcode = phonenumber+'lang';
save(pid, langcode, id, lang);
}).then(()=>{
navigation.replace("AppNavigator");
}).catch((error) => {
console.error("Error adding document: ", error);
});
}
async function save(pid, langcode, id, lang) {
console.log(pid, langcode, id, lang, "inside saveid");
try {
await SecureStore.setItemAsync(pid, id);
await SecureStore.setItemAsync(langcode, lang);
} catch (error) {
console.log(error);
}
}
onpresscard 函数在按钮单击时调用。我得到了预期值 docRef.id 并能够使用以下参数将值传递给保存函数。再次在保存函数中收到它,并且 console.log(pid, langcode, id, lang, "inside saveid") 清楚地显示了字母数字而不是空的值。
如何避免这个错误?
我正在使用 expo react native - Android 模拟器
解决方案
推荐阅读
- java - Java Deprecated APIs 和 SuppressWarnings “deprecation” - 实用方法
- python - 如何在打印语句中开始新行
- spring-boot - 使用spring boot为rest webservices设计多个json对象响应
- android - SmartGLView 后面的 NavigationDrawer
- regex - C# 正则表达式模式匹配关键字
- node.js - 数据显示在 websocket 响应中,但未显示在已解决的承诺中
- android - llvm-rs-cc 缺少颤振
- sql-server - 未显示 SQL Server Management Studio (V17.7) 功能工具提示
- sublimetext3 - 如果侧边栏打开,如何检测键绑定?
- android - 检查 json 对象是否包含特定值