Store remote 2d barcode in React Native - react-native

I am developing a prototype for a mobile ticketing platform where I have to create 2D barcode ticket for the user , currently I am creating 2D barcode from google chart service and displaying it using Image Tag.But Now I do not want to hit remote source every time , I want to download image on first time and save it on local phone source .
So I need guidance to where should I store this image in Async Storage or CameraRoll
Thanks

If you store your images in Camera Roll then they'll be visible to the phone's user when they browse their photos and they could potentially get synced to iCloud. This seems to me to be bad form.
AsyncStorage is a key-value storage mechanism, and the value is expected to be a string. You could use this if you base64 encoded your images, but you'd also have to store another value to track a list of the images you were keeping in AsyncStorage.
I don't think either of these are ideal. Personally I'd look into storing them on the device's filesystem, and fortunately there's a project that seems to enable you to do just that: react-native-fs "Native filesystem access for react-native". I think this is the most natural approach and will allow you to iterate over your stored images.
A final idea is to use a database; you could perhaps use one of these:
https://github.com/mafintosh/browserify-fs (uses level.js behind the scenes)
https://github.com/almost/react-native-sqlite (sqlite)

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.

How can i make offline apps using react-native

How can i make an offline app. For ex. user needs to use an app in offline like bible, dictionary app etc..
How can I make similar like this?
Every mobile app is an offline app unless it communicate with a server via some sort of https request.
Anyway, I would suggest you look into Async Storage (built-in react-native) or i would personally use SQLite.
Make sure to save your data mostly or wherever possible as text and render it on some sort of object to display. which will take less space than images making your apps faster and smaller in size.

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.

NSUserDefaults and adding UIImages to an application via the web

I have an app that uses chat stickers. I would like to add more stickers to the app over time without having to make the user download an update. I understand that I can store data in NSUserDefaults so was wondering if it's possible to get an app to download images from a server to the NSDefaults? Say via parse or a similar service? Is this kind of thing allowed in an app? I read something in the developer guidelines that placeholders could not be used. Any advice on this would be really appreciated. Thanks!
If you want to use parse the store all the images in a table in the parse file storage. Download the images using the Parse SDK. The downloaded images will be cached appropriately by the SDK so you won't need to handle the cache yourself.
You can read more about how to store files with Parse here: https://www.parse.com/docs/ios_guide#files/iOS
NSUserdefaults is not meant to store big files like images. It should only contain small amounts of data.
You will need to download the images and save them locally. To download the image to a file use NSURLDownload.