I've got a weird issue with my Android GCM implementation.
This is the code where I handle GCM notifications:
public class GCMMessageHandler extends GcmListenerService {
@Override
public void onMessageReceived(String from, Bundle data) {
super.onMessageReceived(from, data);
Log.i(this.getClass().getSimpleName(), "GCM push received!");
ACNotification notification = new ACNotification(getApplicationContext(), data);
notification.handleNotification();
}
}
Basically, what this does, it passes notification data to my class called ACNotification
, which then reads the data and displays a notification using Notification.Builder
.
This works perfectly when app is in the foreground. But once the user closes the app, it seems like this code never executes, but the app somehow handles the notification on its own.
It still displays the notification, but Android does it on its own. It doesn't set the proper notification icon (it just uses the Android stock ic_launcher icon).
Any idea what I'm doing wrong? How can I assure that I will be able to handle each notification on my own?