Cordova, save update until internet comes on - rest

I'm trying to make an app using Corodva and I want to be able to save the data if there is no internet connection and automatically update when there is an internet connection.
Can someone give me some guidance?

You can done it by using local storage in html 5.First store the user data in local storage,next setup a function that check for internet connection every time app launches,if true make server request to store the data.After success of server request delete data from the local storage

Related

How to force the flutter app to request new data from the server?

I have an app made in flutter that requests data from a rest api. Currently, every time the app starts, it requests new data from the server. It also does that every 5 minutes.
I would like to know if there is any way to tell all apps from the server to request new data.
The purpose of this system is to avoid polling every 5 minutes and have information in the app almost instantly.
One way that occurred to me is to send a push notification indicating that there is new data. But I don't know how to do this. There are examples for sending notifications using firebase, but I am not using that service.
I also thought about web sockets but I think it is very expensive to maintain an open connection between the app and the server.
Any hold will be eternally grateful
I recommend you to use Firebase Cloud Messaging & Firebase Functions:
Firebase Functions could expose an HTTP Event
https://firebase.google.com/docs/functions/http-events
This event can send a push notification to the App and then you could listen to request new data
https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/example/lib/main.dart

When to create PFInstallation

I am new to using PFinstallations on Parse, and i am a bit confused as to how they work. I have an app that creates a new installation when a user creates an account, and i set the "User" field of the installation to the users userId so i can send them notifications easily later. I dont understand how the installation works when the user logs out or closes the app. In order to be able to always send the user a notification, must i create new installations periodically when these events (ie. logging out or closing the app) occur?
You shouldn't ever need to create an instance of PFInstallation. The parse framework will handle that for you if you access it using PFInstallation.currentInstallation(). But to save it to the backend, you'll need to call one of the save methods yourself.
By default, logging out will have no impact on the installation since it is a method on the user. You can have you own logic that modifies the installation on logout to, for example, clear the user field or channels.
The parse framework writes the installation to disk on the users device. When the app stops running and then restarts, parse can just read that data from disk and have the proper PFInstallation object again.

Does whatsapp store password?? Or are their Sockets always open?

I am trying to figure out how to auto-reconnect a ejabberd socket connection. Like whatsapp, Facebookmessenger etc
For example, when the app is closed, and i receive a push notification to wake the app up and that calls to connect the connection, or if i put the app to the background for an hour, and the connection has been idle too long and get disconnected,then i put the app back to the foreground.
I can only think of 2 ways to automatically connect to the ejabberd server.
1.) To have the JID and Password stored(but this is not good for safety reason)
2.) To have the ejabberd idle connection set to never disconnect a connection(But this uses quite a lot of resources)
Is there any other possibility to automatically re-connect a user to the server?
You cannot stay connected all the time on mobile. This is the case today on iOS and is going to be the same on Android with Android Marshmallow.
So, you need to authenticate and store some form of credentials. It does not have to be a password. If you have a custom auth module in ejabberd for example, it can be a token.
Please, note that you can also store sensitive data encrypted on mobile. Both Apple and Google provide a keychain API that is design to protect the credential. It is not accessible in cleartext from a backup for example.

Mobile Chat - How to store data?

I'm trying to figure out the best way to store data for a mobile chat program.
Basically I will be able to make a group with my friends and they should also see the same group I made.
I'm assuming the best way is to store the data locally on each phone, and then when someone sends a message, it goes to the network, and the network sends that data to each recipients local phone so that it updates the local data.
That way when people are opening up the application, the previous few messages are still visible, since the program will check local data storage.
Is this the proper way to create mobile chat? Or should there be no local storage of data?
The best way will be to store data locally and on the server as well. The reason are as follows
Local data is for the users and will allow the saving on data costs instead of the users always having to get their chat data online everytime they logon. My assumption is that you want to have offline messages the way that Whatsapp chat client has.
Server data is for your reference and also good practice in order to provide the user with data up to a certain point in history if they have lost their device and they login to another device.
I hope this helps and answers your question.

How can we detect that server database has changed from iPhone?

I am developing application in which i have to create url request when server side database is updated.Actually I am trying to make url request when its necessary.So,it will reduce number of request.I want detect that server database is changed.That can be done using push notification but i am looking if there is any other-way.
Thanks In Advance.
You can not detect from the phone when db on the server is changed. You have to make frequent request to the server to see if you have new data. This will consume the users battery and its data from the data plan.
That is why you should push from the server to the mobile devices.