-1

Whenever I kill my android app (removing it from tasklist), I am not able to receive GCM notifications even when priority is high.

Here is my json array

$fields = array(
        'registration_ids' => $registatoin_ids,
        'data' => $message,
        'priority' => "high",
        'delay_while_idle' => false,
        'time_to_live' => 86400   // time in seconds (24 hours)
    );

You see I have set its priority to high. My app is working fine and I receive GCM notifications too, but only when it is in a task list or running in background.
Please help me.

I have tried to get through this thread

device doesn't receive notification if application is stopped

but that doesn't solved my problem.

Community
  • 1
  • 1
  • Possible duplicate of [Android GCM (push notification): device doesn't receive notification if application is stopped](http://stackoverflow.com/questions/12073449/android-gcm-push-notification-device-doesnt-receive-notification-if-applicat) – AL. May 13 '16 at 05:11

1 Answers1

0

Have look here to understand GCM Structure

Reference

This kind of broadcast receivers should receive messages even if my app is closed (not only if my app is in background but even if it was force stopped). If a user force-stops your app from Settings, your code will never ever run again, until something manually runs one of your components, typically the user manually launching an activity (as of Android 3.1). Hence, if the user force-stops your app from Settings, you will not receive GCM messages on newer devices/emulators.

So, is it correct that my app can receive a message (and onReceive() method will be invoked in broadcast receiver) only if it's running or in background (but not closed)? There is no concept of "closed" in Android from an application standpoint. If, by "closed", you mean "has no running process, where the last process was terminated normally", then yes, you should receive GCM messages and other broadcasts. But, again, force-stop is not "terminated normally".

Community
  • 1
  • 1
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41