问题描述
如何通过反应应用程序进行身份验证时,如何实现等功能,请记住我
?我认为未加密的 AsyncStorage
不是最好的方法,因为数据是为用户开放的。我曾尝试使用 realm
,但遇到了无法在Android中使用 expo
来解决的问题来测试应用程序。它说我需要为android编译本机代码并编辑它(在MainApplication.js中添加领域对象创建)。我还不想在尚未发布的情况下编译我的项目。 instagram和其他RN-apps如何存储身份验证数据?什么是最好的方法?
How can i implement feature like remember me
when authenticating via react application? I think unencrypted AsyncStorage
isn't the best way to do it, because data is open for users. I've tried to use realm
, but stuck into problem that cannot be resolved in android using expo
to test application. It says that i need to compile native code for android and edit that (Add realm object creation in MainApplication.js). I don't want to compile my project while it's not released yet. How does instagram and the other RN-apps store authentication data? What is the best approach?
推荐答案
我建议使用像将私有数据存储在
I would recommend using a library like react-native-keychain to store private data in react-native
您可以这样使用它:
// Generic Password, service argument optional
Keychain
.setGenericPassword(username, password)
.then(function() {
console.log('Credentials saved successfully!');
});
// service argument optional
Keychain
.getGenericPassword()
.then(function(credentials) {
console.log('Credentials successfully loaded for user ' + credentials.username);
}).catch(function(error) {
console.log('Keychain couldn\'t be accessed! Maybe no value set?', error);
});
这篇关于在private-native中存储私有数据的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!