What's the best way to trigger an function to run via a request sent by the server?

  • Thread starter Thread starter Android Central Question
  • Start date Start date
A

Android Central Question

Here is the use case:

- the user launches the app and grants permission, the app connects to the server
- at some point in the future, the server sends a request to the app
- the app, regardless of whether it is running or not in the foreground or background, wakes up to run this code

Here are some options I have explored which I am unsure about:

- server sent events
- websockets
- push notifications

Is there a reliable and safe way to do this on android, whether it's Kotlin or Flutter? Can you provide examples or documentation?
 
The "whether it is running or not" part is going to be a problem. If the app isn't running, it's not going to receive the request. It has to be running to receive requests.
 

Trending Posts

Forum statistics

Threads
956,394
Messages
6,968,016
Members
3,163,536
Latest member
android_questions