Receiving Android GCM Notifications when application is in stopped state [duplicate]
Asked Answered
F

1

6

on one of our applications that uses GCM, we've been receiving reports that the app stops receiving notifications when the app has been killed. When the app is started again, the notification appear as normal.

After investigation, we found out that this is due to this change on Android 3.1:

Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications. A background service or application can override this behavior by adding the FLAG_INCLUDE_STOPPED_PACKAGES flag to broadcast intents that should be allowed to activate stopped applications. (Android 3.1 changes)

I inspected the intent that is fired by GCM when a notification has been received, and I noticed that FLAG_EXCLUDE_STOPPED_PACKAGES is indeed set.

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

Since the intent is fired by the GCM framework itself, we cannot change the flags that are set on it, and so we're looking for another workaround.

All ideas are appreciated.

Flattish answered 23/7, 2012 at 14:32 Comment(2)
You're right. I thought that killing an app through the settings menu, or using a task killer, or removing it from the recent tasks all had the same effect, but that's not the case. So this is not an issue at all. Thanks!Flattish
Did you get any solution, I am facing the same issueColombi
H
-3

you should register gcm broadcast receiver from menifist file so receiver will receive notification even if app closed.

Halfhour answered 2/9, 2013 at 15:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.