Is there any way of knowing (via code) if a user is in the app and using it right now? - react-native

I'm trying to incorporate a feature into one of my apps that allows you to message users that are, at that moment, in and using the app. I've searched for a while now, but with no luck finding any article, API, npm package, etc, that supports this concept - if it even is possible.
I'd rather use an API than see when the user was last on the app via a timestamp and then "guess" if the user is still using the app.
I'm using React Native.

Check that AppState equals to 'active'.
https://facebook.github.io/react-native/docs/appstate

Related

How is anyone processing payments with React Native apps at present?

Trust me when I say I've tried every single solution people are currently downloading. tipsi-stripe, react-native-payments, react-native-paypal, you name it.
Every single guide says to link the library using link. Or automatically using yarn/npm. I've tried both ways, doesn't work. The new React Native version is certainly preventing this, and all the npm packages are failing. It seems no one can update the packages to work with react native yet.
If this is the case, how is anyone at all processing payments in react native? There doesn't appear to be any workable option here. Going to have to cancel my client's project due to impossible needs, simply payments.
I would think the best solution is to have a server or webservice that calls an API like PayPal v2/checkout/orders, to set up and capture a transaction. See "Create Order" and "Capture Order" here: https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-side-api-calls
Then, for the approval flow, you can open a secure browser view to the approval_url the create call returns, having set the return_url in your creation to be a deeplink back to your app, which when opened immediately calls your server or webservice to do the capture and respond with success/failure.

Alternative to giftedchat react native

In all the react-native tutorials I have seen so far, on building a chat app, I see them using gifted chat.
After installing the library, it is really buggy and slow. Below are some things I experience when using it.
When I have messages over 100, it takes time to load my chats.
When I press the send button, It takes time as well before updating the chat list(about a second).
Are there any other alternatives to gifted chat?
Slowness or fastness would depend on the "backend" (database and/or server) you are integrating your chat app (or component) with. Firebase (from Google) FireStore or Firebase Realtime DB would be one of the best options to choose from. This might help you in integrating Firebase DB with gifted-chat.
react-native-gifted-chat seem not to be actively maintained.
I found react-chat-elements I did not try it yet.
If you found something else please leave a comment.
good look with your search.

Are there any registration/authentication api's which can be used in React Native

I'm developing an IoS and Android app using react-native, and am now starting to consider all the aspects of user registration, so that typically the person will provide some credentials, and then get sent an email (or possibly sms) enabling them to "verify" their account, after which point they are a registered user.
These registration processes (and subsequent emails/sms's seem to be fairly common , so I'm wondering if there are any API's which anyone has come across which make the job of creating the registration/activation process easier m rather than writing code from scratch ?
Many thanks in anticipation
It depends what you want when you ask for an API. If you're developing backend as well you can use Auth0.
If you want just to implement frontend, I guess you have to write your own code. Consider using something like redux or mobx to store your email and other things after logging in.
Anyways the REST part you have to write on your own. As for views you can google for it, for example there's react-native-login-screen

React-admin | Easiest way to warn user of a newer available version

I have a react-admin app where we are making frequent changes.
Is there an existing plugin or a way to detect a new version of app and provide user with a toast to refresh the application so that they are working with latest version?
If not with react-admin, is anyone familiar with a way to do this easily with react?
I have found some manual way to do this in following places but I am asking here in case there is an existing package or a more elegant solution that I can leverage directly.
How to force update Single Page Application (SPA) pages?
https://medium.com/#kellyrmilligan/create-react-app-let-your-users-know-when-the-app-has-been-updated-with-a-notification-21335d85481c
Any help is appreciated even if its, nothing exist and I should just hand-roll.
Thanks for reading.
This is not the responsibility of React Admin to handle this kind of issue.
You can think of RA as a simple React component that helps you define an admin.
Hence, RA doesn't provide any helper to manage code update or something similar.
You have to implement this refresh system by hand, and your links are a good start for that.
With the serviceWorker you can do that :
https://github.com/marmelab/react-admin/blob/master/examples/tutorial/src/registerServiceWorker.js
But i don't know why in the demo the service worker is not used ?
https://github.com/marmelab/react-admin/tree/master/examples/demo/src

Securely set date that user can't manipulate react-native

Building a simple application which restricts usage based on the date. For example, you can only view a page 3 times per day.
However, if I use the device time, users can change their time and then view these pages again.
Is there another best practice method of doing so? Trying to avoid a call to the server. Using react-native. Thanks
Best practice is only use server time.
you can use following lib
https://github.com/artem-russkikh/react-native-clock-sync
This is kinda tricky without hitting the server.
into
Let's assume that the first time they open your app the user date is correct. (I really don't know any other way checking that in an offline way)
That moment we need to save the current timestamp to the localstorage (called AsyncStorafe in RN).
solution
The only way you can really be sure that the timestamp is correct is keep a task that counts every seconds/minute/hours, whatever is logical in your situation.
issue
Doing this in react native won't get you that far, but we are able to make a Java background service for example that we start as soon as the app closes. Here you should keep up with the time and save this when the app launches to a place where it's also accessible from react native (not sure if AsyncStorage is).
Info
Here you can find some information about bavkground tasks in RN: https://hackernoon.com/easy-os-background-tasks-in-react-native-bc4476c48b8a?source=linkShare-cdf0b7d5ccb4-1538965801
The most secure amd easy way of time cheat prevention is by hitting the server vut if that's not a possibility that this may be a interesting way to still check it. Good luck!