Android Question Advice Needed - Background Polling of a Web Server

Kevin Hartin

Active Member
Licensed User
I have an app that uses Firebase Messaging to receive notifications of relevant activity on a web server, which works perfectly in the background or even when the app isn't running. This enables the users to receive time critical notifications that demand their quick response.

What I also need to to have the web server keep track of all running apps, so is there a way that the app can poll the web server every hour or so even when the app is in the background, similar I guess to how an email app would wake up and check a pop3 mailbox every few minutes?

Thanks,
Kev
 

JohnC

Expert
Licensed User
Longtime User
You could try one of two methods:

1) Use "StartServiceAt" function to run your app (even if it isn't running in the background) every hour and poll the server.

2) Or your server could send out a global "I want every app to checkin now" firebase notification every hour to all devices running your app and then each copy of your app would respond to this notification by polling the server to tell the server that your app is running on that particular device (and configure your app to handle this notification silently)
 
Upvote 0

Kevin Hartin

Active Member
Licensed User
You could try one of two methods:

1) Use "StartServiceAt" function to run your app (even if it isn't running in the background) every hour and poll the server.

2) Or your server could send out a global "I want every app to checkin now" firebase notification every hour to all devices running your app and then each copy of your app would respond to this notification by polling the server to tell the server that your app is running on that particular device (and configure your app to handle this notification silently)
Ive had a look at the StartServiceAt function based on the background tracking sample app and seem to have got it working. thanks...

However, I have decided to go with option 2, which I have been thinking about for a while. I have 3 FB topics subscribed, one for the actual app login, one for the country the app login is associated with and a third for every app login. I can trigger a poll of all installed apps whenever I need to see if they are available, like at 8am each morning, etc.

Thanks for the tips, this morning has been quite productive...

Kev
 
Upvote 0
Top