Receive Android GCM notifications when the app is in a stop state

in one of our applications using GCM, we receive reports that the application stops receiving notifications when the application was killed. When the application starts again, a notification appears as usual.

After the investigation, it turned out that this is due to this change on Android 3.1:

Please note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast items. This is to prevent unintentional or unnecessary triggering of broadcasts from background services from components of stopped applications. The background service or application can override this behavior by adding the FLAG_INCLUDE_STOPPED_PACKAGES flag to broadcast intentions that must be allowed to activate stopped applications. ( Android 3.1 changes )

I checked the intent that GCM issued upon receipt of the notification, and I noticed that FLAG_EXCLUDE_STOPPED_PACKAGES was actually set.

This means that all users who run our application on Android 3.1+ will stop receiving notifications as soon as they kill their application until they restart it themselves. (Pre-Android 3.1 works just fine).

Since the intention is triggered by the GCM card itself, we cannot change the flags set on it, and therefore we are looking for another workaround.

Any ideas are welcome.

+6
source share
1 answer

you must register the gcm receiver to broadcast from the menifist file so that the recipient receives a notification even if the application is closed.

-3
source

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


All Articles