3

I develop an android application with GCM Push Notification. I have started to use the sample of google. Push notifications work when the device is "on". When the device fall asleep, notifications don't appear but they show when I get android device out of sleep mode.

I saw that when I publish a content in Facebook or Snapchat, notification works perfectly in sleep mode so my question is : When I receive a push notification and the device is in sleep mode, how to show this notification ?

**

EDIT

I solve my problem on the server side. I have forgotten to set the property "delay_with_idle" to false in the message parameters.

For more information see the following documentation :

**

NicoN
  • 51
  • 1
  • 6
  • have you read Receive a message topic on this https://developer.android.com/google/gcm/client.html – duggu Jan 15 '15 at 09:40
  • Yes, I have read the topic and I have tested also the sample code of Google. – NicoN Jan 15 '15 at 16:55
  • Glad you found a solution. You may want to consider posting it as an actual answer to this question and mark it as the correct answer. This is for other developers' reference as well. – Koh Jan 20 '15 at 19:07

2 Answers2

2

I solve my problem on the server side. I have forgotten to set the property "delay_with_idle" to false in the message parameters.

For more information see the following documentation :

NicoN
  • 51
  • 1
  • 6
0

What kind of notification are you referring to? A sound notification? An icon in the status bar?

If what you intend to do is similar to the above, you may want to add custom code (like setSound()) in the GCMIntentService class's sendNotification() method. Here is the implementation of the class in the demo.

Koh
  • 1,570
  • 1
  • 8
  • 6
  • I refer to the push notification received by GCM, before I generate the notification that will be displayed. When my device is in sleep mode, my WakefulBroadcastReceiver doesn't receive the notification but it receive the notification only when the device is awake. – NicoN Jan 16 '15 at 08:45