C2DM message is not received - android

why is C2DM push notification message sometimes cannot be received by
the device although the status is success?
Thanks

If the server returns a 200 success message, then the expired key is cannot be the case.
The truth is C2DM is not reliable to always send your message (it may send it with delay, if you send multiple there is a change the order will be altered, or it might not get on the other side at all).
I had a somewhat similar problem, when in my first day of sending messages I was getting the 200 status code but no messages on the device. I got the same answer that the one I'm giving you know.
Also, always make sure when you want to receive your messages that you have an internet connection.

Related

GCM Messages not Syncronized

I have created an app that send messages between devices using GCM , the thing is
if i want to send several messages in a row its possible that one of the sent messages wont be sent instantly and will be delayed.
My scenario is : I have tried to send 3 messages in a row , i received the first and the third one but couldn't receive the second one !!
One day after I received the second message , how could this be possible ?
Is there any way to sync the sending ? and why it took the second message 24 hours to be received ?
Google is very clear about how you get no guarantee that a message will arrive at all.
In other words, don't depend on messages getting delivered. Your system needs to be robust enough to handle this. Perhaps periodically check. Definitely check if the backend has stored messages you did not receive yet.
If you purely rely on GCM delivering your (chat?) messages, then users will very quickly uninstall your app, because it will be faulty.

Is there any limit to push message on same device

Hello I am working on a project where GCM is being used very much to notifify users for certain actions. For this sometimes in a 1 minutes server is continous pushing notification (3-4 messages) to same device.
But I noticed that I receive everytime only 1 message then other 2-3 messages are being discarded. I'm not sure if this is intentional to avoid spamming by Google ?
Does anyone have experience of it. Please share.
Thanks in advance.
If you are sending the messages from your server with the same collapse_key, the GCM server will discard some of them if it receives a message with collapse_key X before it managed to send the last message having the same collapse_key.
If you don't use collapse key, GCM server will discard some of your messages if it accumulated over a 100 messages for the same device that haven't been sent yet.
You can read more about it here.

Gcm delivery not guaranteed

I am using GCM service for my android chat application, sometimes the message sent without any problem and sometimes it fail without any Ack nor Nack..
I don't change any thing, the network is souitable the message is the same as the previuse...
Why does GCM send sometimes and fail sometimes in the same conditions!
point: I send many types of messages other than the chat messages thet the user write directory.
for example I send: ( online status, typing status, profile photo changed...ect)...
these messages sent to my xmpp server via GCM...
does these (many) messages make GCM stop for a while?
I set delay_while_idle = true and TTL=0
sorry for my English I hope you got me!
OK I found that it's common issue in GCM, i.e this is the behavior of GCM.. delay, random thrulling.. I can call this Bug in GCM although the GCM team see that this delays and thrulling are normal and ok ...
So I would like to find alternative...
I found one platforma that not depents to GCM :
http://www.titaniumtutorial.com/2013/10/acs-push-notification-using-gcm.html?m=1

Send GCM notification to an offline device

If I am sending a notification to a device, and that device is offline I get something like:
Error: Unavailable
And I have to resend.
My question is:
Will the GCM server keep these notifications in a queue and automatically resend when the device is online? Or it must be completely handled by me.
Because if the GCM server is going to send them automatically(once the device is online), until it actually sends the notifications, my server assumes they are already sent. How to track the time when the notifications are resent successfully?
I might mark on my server side that the notifications are not sent by looking at the Unavailable error message but cannot make out how to mark them as sent once the GCM successfully sends the notifications.
Thank You
A/c to documentation--- When a 3rd-party server posts a message to GCM and receives a message ID back, it does not mean that the message was already delivered to the device. Rather, it means that it was accepted for delivery. What happens to the message after it is accepted depends on many factors.
If the device is connected but idle, the message will still be delivered right away unless the delay_while_idle flag is set to true. Otherwise, it will be stored in the GCM servers until the device is awake. And that's where the collapse_key flag plays a role: if there is already a message with the same collapse key (and registration ID) stored and waiting for delivery, the old message will be discarded and the new message will take its place (that is, the old message will be collapsed by the new one). However, if the collapse key is not set, both the new and old messages are stored for future delivery.
Note: There is a limit on how many messages can be stored without collapsing. That limit is currently 100. If the limit is reached, all stored messages are discarded.
What I did was to separate the push indication from the payload. In my GCM message I only include a URI to the payload, and I store the payload in a database table accessible through the URI in the message.
When the client receives a message, it could e.g. look like this, with HATEOAS style links:
{
_links: {
message: {
rel: 'message',
href: 'https://my-server.com/push/<messageId>'
}
}
}
The client then goes to GET the message payload from the URI, at which point the server knows that it's been delivered and can update accordingly. Fetching the payload also deletes it.
If GCM re-delivery is not robust enough this also means that the client can choose to manually fetch all pending messages, e.g. when network connectivity is resumed after being offline, by having an endpoint that returns all messages for a given ANDROID_ID or similar. If then later the GCM message is delivered, the client would get a 404 for the URI in that message and treat that as a no-op, i.e., message already handled.
If this is overkill, a light-weight approach to just achieve server awareness of message delivery is to have an endpoint that simply ACKs the reception of a message with a given ID, such as
POST https://my-server.com/push/notifyReceived
{
messageId: <messageId>
}

android push notification c2dm

I have successfully implemented the android push notification using google c2dm.
the problem is,when i push the message from the server i am getting success full deveice id. but the device some time receive push message,some time did not receive.(wifi is fully active)
i want the app to receive all the push message with out any push message lose,becoz each notification is important.
Is there any special parameter need to set or hw i would i confirm that device successfully received the message.
"C2DM makes no guarantees about delivery or the order of messages. So, for example, while you might use this feature to tell an instant messaging application that the user has new messages, you probably would not use it to pass the actual messages."
But you can try to play with 2 parameters:
collapse_key
An arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. This is intended to avoid sending too many messages to the phone when it comes back online. Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server. Required.
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.

Categories

Resources