Android - Sending Push Notifications Via Gcm With App In Foreground/background
Solution 1:
So my large image and icon background color doesn't display.
This is because Android now uses Material design and the default icon for push will be completely white. Also, a large icon should always have a background (i.e. avatar). It is displayed on different background colors, therefore it should be a non-transparent picture.
Please refer to this SO questions: Android Notification Large Icon not work and Android Notification Large Icon not work
Another issue I have, is that the notification won't display if the app is killed or not running. Is this normal?
Android notification is implemented as a Service that is started by a BroadcastReceiver. The reason you are no longer receiving notification when the app is force-close is because this Service has also been force-close. The BroadcastReceiver which starts the Service listens to the ACTION_BOOT_COMPLETED event and the ACTION_USER_PRESENT event. This means the server starts at boot and restarts whenever the user unlocks the lock screen.
As stated here:
Your app can accept GCM broadcasts only as long as you don't kill it explicitly. Once you kill it, it won't receive any broadcasts until the next time you launch it. If, however, you move your app to the background (for example by launching another app or hitting the back button until you move to the home screen or to another app), your app would still get messages from GCM.
So if you force-close your app by going to settings, then push notifications will stop working. When you open the app again, then you will receive the notification.
Post a Comment for "Android - Sending Push Notifications Via Gcm With App In Foreground/background"