Is it a good idea to get user data from local storage and not from API? - api

I need to show logged in user's profile image in the header. But I don't want to call API on every page where header stands. Is it a good idea to store current user information in local storage? So I can immediately get profile image and display in the header without an extra network traffic.

If you want to always get it from the local storage, then how do you want to make sure that they are up to date? I think that's one of the problems which single page applications try to solve it.

Related

Accessing the localStorage of one device from another in react-native

Some days before, i saw a blog post about why we need to keep whatsapp open on our smartphone to make it work on our PC.
It said that WhatsApp fetches the data (messages) from our smartphone and shows them on our pc which seems pretty good as it will lower the load on our database.
So now i wanted to know if there is a way to do so in react-native i.e, access the localStorage of one device from another.
Why i want to do that?
I am building an app where in the profile, i also take the profile picture from the user and i don't want to store it on the database but instead store it locally and serve it from there.
The reason for that is that we need buckets to store media files and serve them from there and i wanted to cut that part when deploying my app.

Is it possible to change vuex store from browser?

I am using vue.js and vuex.
I am storing if user has shared the product on facebook and if yes, let him buy it on a lower price than original. I am storing if he has shared or not on my database and prices are also stored on my db.
When user accesses any of the main pages, i make an api call and load that information in store. Then on checkout page i check that information in vuex store. As i dont want user to go to my vuex store and change that information directly because he would buy the product with a low price without sharing.
Is it possible to change store data from browser or any other ways other than my code ?
I find it unethical.
Hopefully if your information isn't validated by the back-end, there's no way ensuring if some piece of data on front-end is not manipulated. So simply - user can always fake it. However, most of the users will never open devTools and therefore will not know how to manipulate it.
Appendix: when encounter such swindling I usually just share the post with visibility restricted to myself only. So far it have always worked. So, even if one shares it, is it really shared? 🤔
Wish you success

Saving data on phone in a Cordova app

I am making a mobile app using Cordova and I need to save some sensitive and not so sensitive data inside the phone. I am a bit lost on what is the best way to do it.
I need to save:
A JSON web-token (for authentication).
A response from server (I save this to populate my page in case the GET request fails).
Coordinates information when user is logging data to the app (for later upload to a server from with in the app). These will be many separate logs, and can be large in size for local storage ~5-10 MB.
Till now i have been successfully saving everything I need to the local storage but I don't think that is the correct way to do it. So that is why I need some help in deciding what is the best course to take from security point of view.
Saving server response is just for better UI experience and static in size so I guess local storage is a good option to use.
But web-tokens and GPS logs is sensitive information and I dont want to keep it in the local storage as it is accessible from outside the app.
What other options do I have?
Cordova still doesn't have encrypted storage.
Is saving to files a good approach? This here says that data contained inside cordova.file.applicationStorageDirectory is private to the app.So can I use it to save the logs and the token?
The plugin also lists the file systems for Android and iOS and lists which of those are private.
I am currently working with android phones but want to extend the app to iOS later. I have never worked with file systems and caches before so I am a bit lost.

Which is a better way: retrieve images from AWS S3 or download it and store locally in a temp folder to be displayed?

Problem: Retrieve image from S3 and load into UIButton.
I'm currently doing my research on this issue and can't seem to make up my mind. Which is a better way to do it in terms of performance and security issue?
Also, do I need to do caching or store these images in Core Data?
Thanks!
It depends on how you use them. If your app is going to retrieve the images similiar to instagram, or twitter, it's good to download them as the user requested the images via the app.
If once the images are retrieved, the application going to use the images again and again multiple times, it's a good idea to store the images after they are downloaded.
For example, let's think about an application about "social networking" concept, and this app, let's say, has a chat interface which is functional after users add each other. As the users add each other, you download the images of the users and store them on the device, then you can use the profile images of the users by retrieving the locally stored images rather than retrieving them from the server, thus, each time they chat each other, you dont use the bandwidth for nothing. And you should also use a push notification or something that has a similiar functionality for the scenario, when a user changes his profile pictures, all of his/her friends should also be notified (I mean the app is going to be notified by the server) to retrieve and update their local profile image with the newly added ones.
As I said, it depenends on the scenarios of your application/server relationship. If the images you are storing on the AWS S3 are only going to be used only once, then storing them is useless. And If the user is going to use some of the images frequently (like app is a social networking app, friendship app and the friends are going to see each other's photo or uploaded images frequently), then storing them is a good idea, only for some of the users that who has subscribed to each other.

IOS implementation advice

I want to develop an application that stores user's data on an SQL server.
The data contains location and some user note.
I don't want to store anything on the user's iphone.
So what i want to do is an application that gets the user location and check with the server if the location changed for about 100 meters.
I believe this has nothing to do with push notifications.
Am i right? And what do you suggest on how to implement it....
Just Give me an overview of your solution please.
Thanks
This has nothing to do with push notification.
Although, I assume you want to do the same thing than the foursquare application : when you want to checkin, the app sends to the server your actual position, and the server sends back the list of places around, then if you move from a certain distance from your originally point, the app asks the server again for a new list.
So basically, I would just check every 30seconds the position of the user, and if the difference between the last and the current position is above a threshold, just send a request to the server.