Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android push notifications not being received when app closed

I followed the example in the PushSharp repository at: PushSharp Android Client Sample

Everything is working great if the app is open or in the background (by hitting home or back button). If I close the app by swiping it away in the application manager I no longer receive notifications, though.

My assumption was that since the PushHandlerService is marked as a [Service] that it would remain open even when the app is closed and continue to listen for notifications. Is there a way to continue to receive notifications with the app closed, or am I just doing it wrong?

I would include code but what I've got is taken pretty much exactly from the example at the above link.

EDIT:

I tried firing PushClient.Register on app start even through the device is already registered in hopes that this would start the PushHandlerService if it wasn't started. Even with re-registering on each launch of the app I still don't receive notification when the app is closed.

like image 378
jdehlin Avatar asked Sep 02 '25 09:09

jdehlin


2 Answers

Did you tried it with debug, or release mode? I experienced the same when I started my app in Debug mode.

like image 119
Roosevelt Avatar answered Sep 04 '25 00:09

Roosevelt


So, turns out that some Android devices battery or protected Apps settings causes the notification not to display. For example, in Huawei EMUI devices going to "Protected apps" settings and turning on the protected switch enables the app to receive push notification even after the app is terminated.

like image 30
Alish Giri Avatar answered Sep 04 '25 00:09

Alish Giri