最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the best way to store private data in react-native? - Stack Overflow

programmeradmin3浏览0评论

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 pile native code for android and edit that (Add realm object creation in MainApplication.js). I don't want to pile my project while it's not released yet. How does instagram and the other RN-apps store authentication data? What is the best approach?

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 pile native code for android and edit that (Add realm object creation in MainApplication.js). I don't want to pile my project while it's not released yet. How does instagram and the other RN-apps store authentication data? What is the best approach?

Share Improve this question edited Aug 8, 2017 at 9:05 Julien Kode 5,4791 gold badge23 silver badges38 bronze badges asked Aug 7, 2017 at 13:05 IC_IC_ 1,8392 gold badges33 silver badges64 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

What is the best way to store private data in react-native?

I would remend using a library like react-native-keychain to store private data in react-native

You can use it like that:

// 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);
  });

I hope my answer was helpful

发布评论

评论列表(0)

  1. 暂无评论