Android Question Stable service

I want to write a chat program without using Firebase (because I like being independent and I also want to improve my programming skills by doing so)
So this program should work in the background and receive messages from others and create a notification. I know this is very easy with Firebase, but I love the challenge to increase my knowledge. But we all know that this may consume the user's battery a little, and also in most versions of Android, the service activity in the background is limited after a while. But how is WhatsApp or Telegram always active in the background without using Firebase and without getting any additional access from the user, and this activity is not limited or does not damage the battery?
Please fully advise ...
Thanks🙏
 
Why do you think that they aren't using FCM? I'm sure that they are using it.
Your opinion is respectable and reliable, but I thought that large applications and social networks are not dependent on the services of another company and provide the infrastructure independently or, if used, in line with the main function of the application. is not!
Dear Earl, please advise me what to do so that the service never stops in the background? (In all versions of Android)
And whether it is possible to do so with shared hosting or should I provide a VPS?
Don't we create a service in B4A when using Firebase? So how is that service always active and receiving information in the background?
Please help
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
Dear Earl, please advise me what to do so that the service never stops in the background?
Use push notifications.
Any other solution will not work.

Don't we create a service in B4A when using Firebase?
No. There is a service but it is only started AFTER a message is received.
So how is that service always active and receiving information in the background?
It is not.

Push notifications is an OS feature. It doesn't matter whether it is your app or Facebook's app. The only reliable way to receive push notifications is using FCM in Android or IPN in iOS.
 
Upvote 0
Use push notifications.
Any other solution will not work.


No. There is a service but it is only started AFTER a message is received.

It is not.

Push notifications is an OS feature. It doesn't matter whether it is your app or Facebook's app. The only reliable way to receive push notifications is using FCM in Android or IPN in iOS.
If the only way is to use FCM, I know of other services that offer push notification services, so how do they work?
 
Upvote 0

JohnC

Expert
Licensed User
....please advise me what to do so that the service never stops in the background? (In all versions of Android)
Don't we create a service in B4A when using Firebase? So how is that service always active and receiving information in the background?
An important concept that I think you might be misunderstanding is that with the apps that you mention, they aren't "always active and receiving in the background". They are typically NOT running in the background. But they "come to life" when a push (FCM) message is received, they then start to run and handle that incoming data.

So, for your app to "receive" data in the background, your app will either:

1) Have to continuously "poll" some remote server on a regular basis to "check" to see if there is any new data to download (but with this method android might kill your app to save battery), or

2) Be configured to use FCM and then android will run your service when an incoming push message is received so it act upon it (this is the method those apps use).
 
Last edited:
Upvote 0

Marvel

Active Member
Licensed User
WhatsApp uses a combination of firebase and scheduled service. I've caught WhatsApp multiple times on my phone with a foreground service with the text "Checking for new messages" The foreground service closes itself after few seconds. Gmail and google calendar does this also.

I'll assume Telegram does the same without the foreground service
 
Upvote 0

JohnC

Expert
Licensed User
WhatsApp uses a combination of firebase and scheduled service.
I wonder if they do that as a backup in case the device didn't get the FCM push.
 
Upvote 0
Top