GCM notification is not received when App is not running - android

i'v implemented GCM and it works fine except one issue.
if application works in foreground or background notification are consumed by application. However, if notification received while application is killed. Than notification only shown in top bar. But application cant find it even when user launch app.
I notice when message is recived after rebooting device, message is shown ony on message center, but its not found by application. Than, after application started, than, it start to receive messages.

Than notification only shown in top bar.
You put that Notification there yourself. GCM does not display a Notification on its own.
But application cant find it even when user launch app.
The application "found" it to display the Notification.

Related

How can I make an android app start in the background on receipt of a push notification so it can fetch data from the server?

I have an Android app that can receive push notifications. When the app is running either in the foreground or background then I can detect an incoming notification and perform a background fetch to the server.
However, when the app is not running (has not been started) then the push notification arrives but the FirebaseMessagingService.OnMessageReceived method is never called. Tapping the notification will of course start the app but I want the data updated before that happens. The notification is also a "data" notification as required for background fetches.
How can I cause the incoming notification to start the app in the background so it can perform the background fetch.
N.B. I have this working fine in iOS it's just Android where I have been unable to get the app to start up when a push notification arrives.
Thank you
The answer for anyone who trips over this is that the Samsung device I was testing on would not startup, other devices and emulators worked OK. So I need to find some setting in the Samsung A10 that is preventing background startup.

How to make new notification replace older for the same Android app, when it is in background

I am using Firebase to send a notification to my Android app.
When I receive a notification in foreground the method onMessageReceived() is called. If another notification arrives at the same time in the same app, it replaces the older one and shows only the last message.
On the other hand when the application is in background, I see multiple notifications.
I want the notifications to replace the previous ones, in background too. I've tried with collapse-key but it only works when the phone is offline.

Google Firebase Notifications for Android - when app is not running

I am trying to implement a functionality wherein users get notification messages even when the app is not running (neither in foreground nor in background). Companies like Amazon do send notifications and they show up in the notification tray - when tapped, the app opens or whatever intent the message carried with it.
I have been able to implement notification handling when the app is in foreground and background... but when the app is not running, there are no notification messages received at all!
From what I searched around, I think there needs to be a Service running in the background that keeps listening to notification messages - because a service is destroyed when the app is closed. Am I going in the right direction?
Can someone point me to some code that implements or highlights the same.
FIXED... actually.. the problem was MIUI.. Its security app by default disabled autostart for apps.. which blocks notifications from being shown in the system tray when the app is not running.
References:-
http://en.miui.com/thread-37783-1-1.html
https://github.com/firebase/quickstart-android/issues/89#issuecomment-233558184
I you have to see the implementation of FCM for android from https://firebase.google.com/docs/cloud-messaging/
I shows complete understanding of instant notification.

Notification on android device disappears

So I've noticed on my android device (Marshmallow) that a new email (Gmail) notification goes away if I view the new email in my desktop. Same goes for WhatsApp messages. I was just wondering how this is implemented.
Obviously tried Googling this, but all I found was on Clearing the notifications or disabling them.
The application is calling a servlet to see if there are any new/unread messages via a background service. When you view the message on your PC, the service is updated with how there are no longer any unread messages. With this update, the background service in the app sees that there are not any unread messages, so it cancels the notification by its ID with the NotificationManager.

Push Notification not working if we force stop the app mannually

I have moved my app notification code from C2DM to GCM. In this i have a inbox for notification. Everything is working as expected. But notification doesn't work in below scenario:
I have installed the app. If I send notification, it comes to notification bar and in inbox also. If i force close the application from settings. Now, If we try to send the notification again to the device then we are not getting notification in notification bar but it is coming in notification inbox.
Note: I am using android 2.3.
For ICS and Jelly Bean: I have read in this post that if you force stop the app from settings then u will not get notification. Is it same problem here?
thanks in advance.
Yes that's true. If you force stop the app, the message can't be received (unlike iOS/APNS). The Xtify service will be restarted and messages will be received when the user re-opens the app or the user restarts his/her device.

Categories

Resources