This is by design and follows the normal UI conventions.
Luckily the plugin is open source, and you can change the behaviour.
Incoming push messages get processed by the GCMIntentService
.
The onMessage()
method checks if the app is in the foreground or not:
if (PushPlugin.isInForeground()) {
extras.putBoolean("foreground", true);
PushPlugin.sendExtras(extras);
}
else {
extras.putBoolean("foreground", false);
// Send a notification if there is a message
if (extras.getString("message") != null && extras.getString("message").length() != 0) {
createNotification(context, extras);
}
}
Modify the if (PushPlugin.isInForeground()) {...}
statement to accomplish what you need.
Another way would be to modify the code in PushPlugin.isInForeground()
itself.
public static boolean isInForeground()
{
return gForeground;
}
However be aware of any unwanted side-effects of changing this code. There may be other functionality that depends on this method (now and in the future).
See related post for a good explanation of how Parse push messages are received: