Securely set date that user can't manipulate react-native - 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!

Related

Can NUXT3 observe the values of server variables in real time?

I'm a developer who just started NUXT3.
Is the following scenario possible using NUXT3 and related modules?
An integer variable exists on the server.
The screen of the customer accessing the web page displays the current value of the variable.
Each customer can increase the value of that variable by 1 through the button.
At this point, the value should be automatically updated on the screen of all connected customers.
I know Vue.js and Websocket very well, so I've already implemented these programs using both.
But websocket is too cumbersome.
All customers must be managed in a clientList array.
Every time a variable changes, data must be sent to every time customers.
If the customer's phone's network is unstable and the connection is disconnected for a while, they should also handle the error during that time.
But nuxt 3 is a server-side rendering platform!
I feel like what I want is possible.
Or, even if it's not a web socket or socket.io, is there a good replacement for this real-time communication?
Once you have your SPA hydrated, there is no way to re-render on the server without nuking all of it with a hard refresh. So yeah, websockets are probably the best way but others solutions exist too: https://stackoverflow.com/a/74405860/8816585
Those tools are meant for that and work well so use them.

Using third-party API to constantly(dynamically) refreshing the data List in Flutter framework

I'm trying to make a simple app using Flutter, cryptocurrency price tracker. Using this API to retrieve a data. That how it looks:
The problem is, it only retrieves the latest data and do not updates as the price changes every time. It will change only after restarting an app. I was thinking to add a floating refresh button but i seems an old school. SO my aim is to let it update the price by itself,in real time(LIVE) without USER doing something, every time there is a change in price. My question is, what technology is behind this ? How could I implement this ? What should I Google in order to find the required knowledge ? Who could give me the right direction to think and learn. I don't really know the special terminology for this concepts, tried my best to explain the question. Thnx!
How could I implement this ?
Following are the steps that you need to follow.
Create a stateful widget with a Periodic Timer object. setup the timer value, say 10 seconds.
Now you will get a callback for every 10 seconds. So, from that callback method, simply call the API end point to fetch the latest data.
Use setState method to show the latest data on the UI.
Thats all, now your app will refresh the data by its own for every 10 seconds without any user interaction.
You can use web sockets.
https://flutter.dev/docs/cookbook/networking/web-sockets
This will let you push updates to the client without polling in real time.

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

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

Perform a task every day even if running only in background

I need my application to perform a background task every day, but it does not comply with Apple's specification for running in background.
It's none of these: audio, location, VOIP, news stand, external-accessory—, Bluetooth-central.
I'm planning to use local notifications, but the point is, that if the user doesn't open the app (and just leaves it in the background), I cannot plan new local notifications.
What should I do in this situation?
Make something else.
Seriously, if your app doesn’t at least technically fit one of those categories, you’re not going to be able to get it to do background work in a way that’ll get you approved for the App Store.
I’ve seen apps that added specific functionality in one of those categories, orthogonal to their actual purpose, to be allowed to run in the background; for instance, there’s a couple of weather apps out there that play a continuous audio file—one of the available sounds being a silent one—in order to be able to update the lock screen’s “now playing” image with live data. If you don’t mind your users being unable to listen to any other music, and have your app continuously active (which might cause additional battery drain), that could work. But if you’re trying to have your app invisibly do things in the background, without interfering with anything else, in a way that’ll get you into the App Store, you’re probably out of luck.
Four options:
Go for jailbreak
Try to get in the app store as one of those types of apps, making up a feature that uses one of those types.
(my favorite) Really rethink your system, is it really necessary to schedule background tasks? Can't the user wait a bit when he opens the app? That loading can be performed in background. And can't you offload some of the work to a webserver? Are you collecting data? You shoudln't without the user consent.
Let your user know that it's important for him (he's the one using it right?) that he opens the app once a day.
I think I covered all yohr options except the one already covered by Noah.

Time limited Shareware

I'm thinking about making a time limited full version of my App, so users can try it for example 7 days.
Is there a recommended Obj-C library?
First of all do not store your data inside the app. Otherwise it would be simple to delete the App from the filesystem and download it again restarting the countdown. Store it in User preferences or Application Support instead. You could use a plist for this. You could also use a hidden file if you like. Just don't make it too complicated or too invasive. Your app can be cracked no matter what security measures you use in the end. Just be fair enough to the end user that could be a prospective customer.
Here is a very nice link on the topic of implementing a time-limited trial in Cocoa:
http://lipidity.com/apple/shareware-licensing-techniques/
Without possibility to protect your data from manipulation/deletion it is not possible to do.
How do yo check, if it is first start of your application, if all your data is wiped out.
Some alternative is "hardcoded" id token and connection to the rest of world (at least for first start, to grab any kind signed data key)
Maybe you could use a server where store UUID's and first time they launched the App. Then, Each time they open your application, it asks your server if they can use it or not. It's harder than store dates on device but if you do that, users will access your application simply changing the date of the device on Settings.