0

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.

  • 1
    It sounds like you should think about the problem more and maybe write down some solutions. Maybe psuedo code some of your options. I would also try asking the person who gave you the challenge for some more information. See what information they will let you mock and see what they really want you to focus on. – Anthony May 15 '20 at 18:55
  • I agree with @Anthony... also, keep in mind that the notification comes from the back end, so that part of the solution doesn't have anything to do with your app. That would require some kind of browser or website integration to detect the login, and notify your backend, so it can notify your app. – bmovement May 15 '20 at 19:39

1 Answers1

0

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.

  1. 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.

  2. 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.

  3. Make sure you use database security rules to ensure the device tokens and codes are secured.

Dharman
  • 30,962
  • 25
  • 85
  • 135
xcodesucks123
  • 424
  • 4
  • 8
  • 1
    Excessive self promotion may be perceived by the community as spam. Take a look at the [help] and specially the last section of [What kind of behavior is expected of users?](https://stackoverflow.com/help/behavior): Avoid overt self-promotion. You might also be interested in [How to not be a spammer](https://stackoverflow.com/help/promotion) and [Are taglines & signatures disallowed?](https://meta.stackexchange.com/questions/5029/are-taglines-signatures-disallowed). – Ian Campbell Jul 14 '20 at 22:38