user3822119
user3822119

Reputation: 90

The right approach to listen to GCM notifications

I'm trying to build a GCM notification listener, which will basically use the notification to flag the user that some operation should be made (which involve communicating with my remote App-Server). I assumed that I should create a UI-less application running on the device's startup and listen to the GCM notifications and issue the internal android notification. When the user opens the notification an activity will be opened which will do the rest of the job with the remote App-Server. Looking at notification examples it seems to me that I may be missing some basic understanding since all te examples which I had found use a UI application to manipulate the notifications. What do I miss?

Upvotes: 0

Views: 650

Answers (1)

Eran
Eran

Reputation: 393841

The common use case for handling of GCM messages in Android apps is as follows :

  1. Your app registers to GCM upon startup and sends the registration ID to your server.
  2. Your server sends a GCM message to your app.
  3. You app receives the message in a broadcast receiver, which usually starts an intent service.
  4. The intent service usually displays a notification to the user.
  5. The user taps the notification, which starts an activity of the app.

You can see this use case implemented in the official GCM demo and in many other examples.

The fact that the app you wish to develop has no UI doesn't prevent you from implementing the exact same use case.

Upvotes: 1

Related Questions