I used to develop in android previously and i used to used SharePreference for storing user tokens. Is there anything such available in react native for both ios and android?
Keychain Services allows you to securely store small chunks of sensitive info for the user. This is an ideal place to store certificates, tokens, passwords, and any other sensitive information that doesn't belong in Async Storage.
const options = { url: URLs. addLeads, method: "POST", params: { token } }; This will add a token query parameter with a correctly URL-encoded value. You don't need to change the headers; the Axios defaults already have you covered.
If you're using create-react-native-app
or exp
, you can use Expo.SecureStore
to store your token.
import {SecureStore} from 'expo'; await SecureStore.setItemAsync('secure_token','sahdkfjaskdflas$%^&'); const token = await SecureStore.getItemAsync('secure_token'); console.log(token); // output: sahdkfjaskdflas$%^&
Details: https://docs.expo.io/versions/latest/sdk/securestore
Update in Dec 2020:
The SecureStore module is now become expo-secure-store
import * as SecureStore from 'expo-secure-store'; await SecureStore.setItemAsync('secure_token','sahdkfjaskdflas$%^&'); const token = await SecureStore.getItemAsync('secure_token'); console.log(token); // output: sahdkfjaskdflas$%^&
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With