Android - stop (intercept) a C2DM Push notification if an application is running?

I have implemented C2DM (Android Push Notification) in my application and everything is working fine. However, when my application is running, I can receive notifications. Can I find out how, if I can stop the push notification from signing in if my application is running? I only want to receive push notifications only when my application is down. Since, as far as I know, APNS (Apple Push Notification Service) will check if the application is working or not before sending a push notification. Does C2DM do this too?

Thanks to everyone in advance!

+4
source share
2 answers

@ Muzhib is right. I encountered the same problem as you, I would like to stop push notifications if the application is running. I managed to solve the problem using the code here: http://kpbird.blogspot.com/2011/08/android-check-application-is-running.html

Use this code snippet to check if your application is working or not. Then, if the application is running, I did nothing for it, if it is not running, then I would send / receive push notifications. Hope this helps!

+4
source

Well, you can turn off your notifications when the application is running, in other words, push messages will still get access to you, but you have a control for notifications or not.

If the application is running or in the foreground there are no notifications yet Notify ...

+2
source

Source: https://habr.com/ru/post/1412724/


All Articles