I was given the following challenge: "I want you to develop a mobile application based on react native. It's an authentication app. Which means I want to open a website and try to login and when I do. I will receive a push notification on the device when I open it I will get a code to enter on the website when I do I should be logged in".
I didn't start with the code yet, I'm trying to figure out how the process will be done. I was thinking of implementing a TOTP algorithm using Node.JS, but then I got stuck on how the app will know that we logged in on a website and send a push notification.
You'll need some sort of server that the website will make a request to. When the server gets the request, it will need to look up a device token for the user logging in, and send a push notification to that device. One simple way to do this is with firebase database and cloud functions.
Run a simple api on a cloud function, which you will call from the website on login. It will check your database for user info and device tokens, and send an appropriate push if necessary. You can use nodeJS for this.
When a user signs up for/logs into their app, use react-native-firebase to get their device token, update this in your database. Add handling for when a notification is opened, and give them a code.
Make sure you use database security rules to ensure the device tokens and codes are secured.