Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

I would recommend 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 ??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...