Getting xmpp messages while app is in background in android - android

As the app disconnects it stops getting messages from xmpp server. For background notification purpose, I am using GCM service. Now, Just like WhatsApp I want my app too to receive the messages in background and save them in sqlite.
Is it necessary for this task that my app would always be connected to
xmpp server?
Will it not load the xmpp server Since, so many sessions the server
will have to keep alive?

Don't set keep alive for less then 10 minutes this will load the server.
When app is in the background then you have to send push notification via gcm for android and apns for iPhone. For this to implement you need to implement plugin on openfire.
1 up if you like the answer. Email me at cvofjaspreet#gmail.com I can provide you code for plugin also.

Related

How to push notification with socket service in background when application is closed in ionic 4?

I must push notification from my own socket side server when the application is closed or application is in the background. Where do I need to write a typescript code in my project to solve this problem?
The push notifications require registration between your mobile device (the app) and the Push Notification services (Google GCM/FCM or Apple APNS).
Registering your application via a unique identifier will allow your application to receive notifications (actually the OS will handle them) anytime, even if the application is closed, in background or foreground.
If you want to send data (represented as notifications) from your server via sockets you should consider implementing a background handler to listen for that data. If the app is closed, you may need to use a Plugin (native code required) to wake up your app and listen for changes.
Have a look here to understand better how the Ionic Apps are working in background with Sockets.

React Native listen to Websocket to send Push Notifications?

I have an existing server that allows websocket connections, and publishes certain messages.
I'd like to start some kind of background task that can listen in on these messages and send a push notification to the user (even when the app is in the background).
What's the best way to do this? I've found react-native-push-notification for sending local push notifications; but so far I haven't really found anything that will let me keep a background process running. Looks like https://facebook.github.io/react-native/docs/headless-js-android.html might be promising.
So, after some research, I've realized this is just imply something you don't do.
You instead have to have your app register with Google's GCM Servers (in the case of android). You get back a token. You then send that token along to your server. When you want to push a notification, your server has to send that token along with the notification data to the GCM Servers.

Sending Notifications to android app? How to implement server-side (own server, FCM)?

I come from the JavaEE development and I'm totally new to android app developement and I'm a bit confused how to implement my requirements. I have a server, where the user has to authetificate and can perform CRUD-Operations via REST-webservice. When a specific event is triggered server-side I want to send a notification to the app. The user should recive the notification even when the app is not running at the moment.
So now my questions:
What do I need on client side so I can recieve this notifications even when the app is not running? Or do I recieve them even if the app is not running? The data input from the notification needs to be safed app-side.
How do I send a notification from my server if the event is triggered? Do I have to use FCM(/GCM?) or can I directly send notifications from my server to the app?
Any help is appreciated!
Typically, 'instant notifications' are done via websocket severs, for mitigating the process of setting one up yourself, people typically use something like Pusher, which has a library available for java, or you can obviously use FCM/GCM. In conjunction with this document you should be able to keep the service running on the andriod app even when running in the backround so you can still send notifications, just remember you'll have to still attempt to detect if they have internet connection or not when sending out those notifications.

How to get updates from a working server to an app if its not running (Android Studio)

I'm working on an app that is very simple (it's a chat app)
I have a server and Android users.
for example say we have 2 users, user_a and user_b.
user_a enters a chat room and sends "hi user_b" (user_b is registered to this chat room)
when user_a sends his message, it is also sent to the server.
I'd like to make a service that will be running always in the background even when the app isn't running. that service will check for new updates each time.
so I'd like user_b to receive the message, and it will appear as notification.
in order to do it my approach is to make a service that will continuesly run in the background. any suggestions?
The best way to do this is sending messages to your server, which will notify recipients via GCM in real-time. You need to create a gcm intent service so you can catch gcm messages and handle them properly in your app (build a notification and updating chat activity)
You can also broadcast the messages you receive from gcm notifications so you update your chat online (like all chat apps do…)
I recommend you to read about GCM and broadcast

How do I keep a user permanently online with Smack on Android?

Okay here is my problem where i am stuck for so many days.
I am developing a simple chat application with the help of XMPP client - SMACK.
Everything works fine for me normal chat process from one friend to another, also added the notification part.
What i am not able to do is if i forcibly close my application the whole session with SMACK stops.
I am not able to send the message to the user who had closed the application.
Now, how do i keep the status of the user permanently online so the he can also receive messages even if he had closed the application.
You can't. If the application is closed, the user is no longer online and the server knows that. You can still send them messages, but it is the servers job to store offline messages, but that means the server has to be configured to do so.
They can be retrieved once the user connects again.
Here are a couple of suggestions to work around the problem
Have a go at implementing either:
A long running service that connects every x minutes (polling solution) I personally advise against this as it's a drain on network and battery.
Implement GCM in your app and server.
It wakes up the app when a message is sent and connects to the server to retrieve the payload. (in fact with GCM over C2DM you can send the payload over google and not even have to connect but I steer clear of this)

Categories

Resources