Keep app open like whatsapp


#1

Hi All,

I’m building a chat application using Ionic and Node.JS.

Currently, when the app is opened the node server will flag the user as ‘Online’ and any other ‘Online’ users can send each other messages and audio calls. However if a user navigates out of the app and closes it, the user is then flagged as ‘Offline’ if an Online user tries to msg an Offline user the msg will not go through or the notification will not send.

My question is, how can I keep my users ‘Online’ forever? Making it so the app cannot close completely. That way the network connections stay open and messages + notifications will still be sent and received. is there a plugin I can use for this?

Thanks!


#2

Ok, I think there’s 3 possible things you’re talking about here:

Keeping the user logged in -
In this case you’ll want to persist the user session to local storage. I’ve recently started using Googles NoSQL User/Data storage solution called FireBase. Not only does it have a lot of off-the-shelf features for user auth, but with AngularFire https://github.com/firebase/angularfire you can easily deal with data synchronisation which leads me onto my second point…

Keeping data synchronized -
Again, with FireBase you can synchronize server/client data

Sending notifications when app is closed -
Ok so my knowledge on this is fairly shaky so someone else will probably need to fill in the gaps here. But what I believe you’ll need is a cordova plugin to natively ‘pop up’ the notifcation. Then some form of messaging/notification queue that dictates when a notification should be sent to the users device


#3

Hi,

Thanks for your reply!

So right now i’m using NoSQL(CouchDB) for user management and storage. Would I need to switch to a firebase solution or is there something that would be compatible with my current setup? I’m not entirely sure what to use for data sync.

Thanks again


#4

Well I guess it’s for you to decided what will be more efficient for you. Without knowing CouchDB myself, but you would have to hand write methods to store the data locally, either with browser local storage or through the native SQLite. Then you want watchers to monitor your conversation objects and check for any changes.