Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sometime Not Receiving push notification GCM in Mobile

I am facing a strange problem. I am getting push notification in my mobile, if it is connected to the internet at that point when message has been send from the server side. But if it is not connected to the internet at that time and rather I am connecting to internet after some time. I am not receiving that notification. According to my knowledge all those notifications should show whenever we are online, because GCM server stores all those messages. I am receiving notification for all other apps. Also I have given wakelock permission in manifest. What might be the problem? Anything from server side, client side or mobile? Please help...

This value is send to GCM server from 3rd party server(.Net server):

String postdata= "collapse_key=score_update&time_to_live=2419200&delay_while_idle=1&data.message=‌​" + 
message + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + deviceToken + ""

Thanks in Advance

like image 998
ARIJIT Avatar asked Feb 07 '13 07:02

ARIJIT


People also ask

Why is my phone not receiving push notifications?

If restarting your phone didn't do the job, one of the most common reasons notifications don't show on Android is because of the notification settings of the app in question. It's possible that you may have mistakenly messed up with the default notification settings, and so now you're not receiving them properly.

What is GCM push notification?

Google Cloud Messaging (GCM) was a mobile notification service developed by Google that enables third-party application developers to send notification data or information from developer-run servers to applications that target the Google Android Operating System, as well as applications or extensions developed for the ...

Why might push notifications stop working?

You may have accidentally turned off either the system notifications or the app's push notifications. Go to settings and make sure both of these options are enabled. To enable an app's notifications, turn on the show notifications trigger.

How do I enable a push notification on my phone?

Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.


1 Answers

delay_while_idle=1 contradicts Also I have given wakelock permission in manifest

delay_while_idle=1 means the message won't reach the device if it's idle (off, offline, locked screen, etc...). Change it to 0 if you want your wakelock permission to make any difference.

Just to clarify - the message should reach the device after it stops being idle (as long as it hadn't been idle for too long, where "too long" is determined by the specified time_to_live).

Here's the relevant quote from GCM documentation :

delay_while_idle

If included, indicates that the message should not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent. Optional. The default value is false, and must be a JSON boolean.

time_to_live

How long (in seconds) the message should be kept on GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON number).

like image 157
Eran Avatar answered Oct 21 '22 01:10

Eran