async-storage | React Native hook for Async Storage | Storage library
kandi X-RAY | async-storage Summary
kandi X-RAY | async-storage Summary
React Native hook for Async Storage
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- A view of storage items
- Update a storage item
- Get item from storage
- clear the async item from storage
async-storage Key Features
async-storage Examples and Code Snippets
Community Discussions
Trending Discussions on async-storage
QUESTION
I have a React native front end where I use invertase/react-native-apple-authentication to handle Apple Authentication.
Then I have a NodeJS back end, where I use A-Tokyo/apple-signin-auth to handle Apple authenticated users and let them access routes.
I made this authentication based on this article.
I want the users to be able use the app without logging in again without a time limit.
Therefore I save the identity token, which I get when the user does the first sign up in Async Storage in the front-end. Every time the user tries to access routes the user will be checked if he/she has a identityToken in the Header in my isAuth
middleware in the NodeJS backend for the respective request.
I can see in my logs not sometimes requests get the following error the backend in my isAuth
middleware:
JsonWebTokenError: error in secret or public key callback: input error: Invalid id token public key id at /app/node_modules/jsonwebtoken/verify.js:96:19 at _getIdTokenApplePublicKey (/app/node_modules/apple-signin-auth/lib/index.js:1:5730) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5)
The error is thrown in the apple-signin-auth
library when executing this code:
ANSWER
Answered 2022-Mar-29 at 08:04As far as I understand the workflow, you verify the identity token in the backend only once when the user has authenticated themselves using "Sign in with Apple" on the device.
If verifying the identity token in the backend was successful, you receive a refresh token in the response. You are then supposed to save this refresh token in your backend and verify the refresh token once a day to check if the user is still logged in with Apple. What does that mean? For example a user could revoke access to your app. Or a different user could log in on the Apple device.
By the way, if you verify the refresh token on every request (read multiple times a day), you risk Apple throttling these requests.
Bear in mind that this doesn't free your system from rolling its own session management meaning that your system sends its own session ids back and forth between the backend and front-end. Once a day, you check the refresh token associated with a session to see if the user is still logged in.
Disclaimer: This is how I understood the docs of Sign in with Apple. In other works, I have no experience implementing it. Hope it helps nonetheless.
QUESTION
I have a login page. There, the user enters data and submits to the API. The API gives an answer that there is such a user and gives him an id from the database. I write this id in storage. Next, the user is taken to the home page. There is a component that is responsible for getting the username (and indeed all other data) the essence of the component: 1 The parameter receives an id and forms it into a json request. 2 The parameter sends this request to the API and receives the user's data in the response (if the id matches) 3) return which draws the interface and gives the user data from the API response
Problem: When changing an account (or re-logging in), it gives a json request error (in fact, the API does not accept an empty request, so it rejects it) The point of getting an ID is 100%. When the application is updated again, the id turns out to be generated in json and after that I already get data about the user.
How to fix it? In fact, it must first receive the id, and only then the id is sent and the data is received, however, at the first entry into the application, he does not want to receive the ID immediately, but only after a reboot (ctlr + s in VS code)
//LOGIN.js
...ANSWER
Answered 2022-Mar-11 at 14:21I am not 100% sure I understand the question so here a few hints I would give you.
- You can pass parameters when navigating like this:
QUESTION
Shaking the android device and hit Debug, and it crashes every time right away. From the Android Studio logcat, it shows No source URL loaded, have you initialised the instance?:
...ANSWER
Answered 2021-Dec-21 at 02:56After some more search arounds, found this is a known issue in react-native-reanimated. As their website points out
Please note that Reanimated 2 doesn't support remote debugging, only Flipper can be used for debugging.
Another github issue also pointed out this issue
This is expected, you can't use remote debugging with turbomodules (which Reanimated v2 is using). Check out Flipper to debug your app.
https://docs.swmansion.com/react-native-reanimated/docs/#known-problems-and-limitations
https://github.com/software-mansion/react-native-reanimated/issues/1990
Removing this library fixed the issue.
- Remove the react-native-reanimated dependency in package.json
- Remove related code in android's MainApplication.java
- yarn install or npm install
- Go to the ios folder and run
pod install
- Go the the android folder and run
./gradlew clean
- Rebuild the app.
yarn android
andyarn ios
Another alternative is to use Flipper for debugging instead.
QUESTION
So I wrote a to-do list app, following a youtube tutorial, but it does not work as intended, it does not save the changes made so when you open the app again it starts as nothing happened. I installed async storage with the command npm i @react-native-async-storage/async-storage
and linked it with the command react-native link
. Maybe I'm linking it wrong or idk I'm completely new to this.
Here's the App.js:
ANSWER
Answered 2022-Feb-26 at 20:21You have a typo in your code
You set an item with this line of code
QUESTION
It was working fine before I have done nothing, no packages update, no gradle update no nothing just created new build and this error occurs. but for some team members the error occur after gradle sync.
The issue is that build is generating successfully without any error but when opens the app it suddenly gets crash (in both debug and release mode)
Error
...ANSWER
Answered 2022-Feb-25 at 23:22We have fixed the issue by replacing
QUESTION
I have a react-native project. After the bitnary (jcenter)
shutted down I started to replace it. Currently I'm using mavenCentral()
.
Also I'm using the react-native-intercom (wrapper for intercom)
.
When I'm trying to build gradlew assembleRelease
. Its throws me an error.
ANSWER
Answered 2022-Jan-23 at 12:38I solved it. If you are using the react-native-intercom wrapper. You need to update it, after update everything works fine
QUESTION
I'm creating an Auto-Logout functionality (which needs to be logged out every day at 9 am) in my react-native app, so for that I came up with the logic:
So what I'm doing is, lets say I have my parent stack component, in that inside the useEffect, suppose the app is just opened, I will check if I have lastRunTime
saved in async-storage
, if true, then I will create a new Date object pointing today's current date, then if 9:00 am comes in between these 2 times, I will logout and set lastRunTime as Date.now().toString()
in async-storage
.
ANSWER
Answered 2022-Feb-22 at 16:18First of all, just to clarify, useEffect(() => {...}, [])
only runs once, when you create the component. It can be considered as an equivalent of componentDidMount
from older terminology.
So, if you want to log the user out at 9, if the user opens your app at 8:59 and waits until 9:01, they won't be logged out, because useEffect
ran at 8:59
. You could solve this issue with any kind of interval and periodically check if time is past 9:00.
The most ideal solution would be is to handle this logout feature backend side, if you have control over the backend, as that has most certainty that if backend is online and logic is correct, your user will be logged out.
The second most ideal solution would be is to have some kind of background task scheduled in your app, that makes sure that the user is logged out, regardless if your app is open.
The third most ideal solution is to use some kind of interval as I've explained above but that only works if the app is open.
Problem with your current code:
QUESTION
I have got the following package.json
file. Main purpose is to use Expo 44 with native-base (version ^3.0.0
). I could not figure out why such an obvious combination does not work. (Could not find online for native-base, which Expo versions are recommended either.)
package.json
:
ANSWER
Answered 2022-Feb-19 at 08:53It seems native-base searches "react-dom": "*"
and could not find it so somehow uses "react-dom": "17.0.2"
and it in turn looks for "react": "17.0.2"
which conflicts with expo's "react": "17.0.1"
.
So adding "react-dom": "17.0.1"
as dependency solved the problem. By this way "react-dom": "*"
finds "react-dom": "17.0.1"
which is dependent to Expo's version "react": "17.0.1"
. (Please let me know if this conclusion is wrong.)
Following are the ones related with native-base
and these versions should be used otherwise the npm install
fails for Expo 44:
QUESTION
I am developing an app using react native, every time I refresh the app on the emulator in onAuthStateChanged and currentUser from firebase I get null.
I have read about waiting onAuthStateChanged to get a status update but I never do, so I guess I misconfigured something.
I am using expo 44, react 17, firebase 9.6.5 but in compat mode (planning in fully migrate later)
My first attempt of solution was trying to add persistence: firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
...ANSWER
Answered 2022-Feb-10 at 05:56I had this exact same issue. I solved it by adding "firebase": "^8.9.1"
to package.json, running yarn install
and changing the import import firebase from "firebase"
(remove all the other imports you have). Apparently selective imports have a bug in v8, but at least it works well :)
QUESTION
I'm only seeing mention of changes in babelrc etc. online for this message. I've tried to remove the dependency that gives me this error and it appears that then next dependency evaluated returns the same message.
The error is coming from any/all of my node_modules folder and the code is correct. I'm guessing something has changed w/ versions of something in my dev dependencies but not sure how to track it down...
I'm using RN 61.5 old I know but this is a production env and can't update atm. Any help on where to look to find the issue please?
...ANSWER
Answered 2022-Feb-09 at 06:34we decided to take the big plunge. upgrade the project from rn 61.5 to 67! it only took 2 days ;) wish we would have started there...
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install async-storage
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page