gcm user notifications

708 views
Skip to first unread message

Makesh Kannan

unread,
Oct 4, 2013, 2:21:06 PM10/4/13
to andro...@googlegroups.com

I am trying to understand while sending push notification,.I was expecting the message to be sent to all devices with same notification key, should I include both notification key and registration_ids in the payload.

 

But the notification was sent to only one device – only for the registration id that is mentioned below in the payload.

 

Looking at http://developer.android.com/google/gcm/notifications.html,  I think I should post to https://android.googleapis.com/gcm/notification. instead of https://android.googleapis.com/gcm/send

 
and I should use send operation. But there is no sample payload for send operation. Can you please give me sample payload for send operation.

 

The follwing works but the notification was only sent to only one device, eventhough I have two devices under same notification key.

 

Post to https://android.googleapis.com/gcm/send

 
Request Details
 
Request Size: 510 

Request Method: POST 

Request Content: {"registration_ids":["APA91bHjVoaAFnfTc2_tRfKNlHLADm9F0H01v2JhYUQdFsW5e15UToV4MklVXOreJ8vx8nmvyCUgXUMW0HnavRrqCqrtJaHsyYFP_bIMG4iagSS9DYkFkobQD8UaNKJUOLV2-v8TemQ38yWGOt7uxaOSZqru13lC-lC4lHR0-BDl-SzX_rOKVwc"],"data":{"quiettime":"false","badge":"9","title":"USAA","alert":"detail","sound":"default"},"notification_key":"APA91bHuyJIMwlz8_e8z6yq5qdPc32z9fAp9EV66EWl0jq_-A1F5-4nMlGH0EwPFpsHuCjhylKipfa4Z4IVagDsCDeNyi6jvbCIGq6iNf8IFLqH1bXH-_PSMjslLSQE15GCxCmZ9nTOX","collapse_key":"AlertMsgSync-4","time_to_live":1} 

Request : accept-language:en, accept-charset:iso-8859-1,*,utf-8*, user-agent:usaa, host:, connection:close, content-type:application/json, content-length:510,   

Response Details
 Response Size: 143 
Response Content: {"multicast_id":5827412257797868612,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1380907967419523%395c8a4620a93e87"}]} 
Response Header: Expires:Fri, 04 Oct 2013 17:32:47 GMT, Cache-Control:private, max-age=0, X-Content-Type-Options:nosniff, X-Frame-Options:SAMEORIGIN, X-XSS-Protection:1; mode=block, Alternate-Protocol:443:quic 

Attila Oláh

unread,
Nov 4, 2013, 3:27:09 AM11/4/13
to andro...@googlegroups.com
On Saturday, 5 October 2013 01:21:06 UTC+7, K Mak wrote:

I am trying to understand while sending push notification,.I was expecting the message to be sent to all devices with same notification key, should I include both notification key and registration_ids in the payload.


I don't think so. It should work using only the notification_key.
  

But the notification was sent to only one device – only for the registration id that is mentioned below in the payload.


This is happening to me as well. It seems that the API simply ignores the notification_key parameter. See my question here: http://stackoverflow.com/q/19720767/252239
I don't think so. `/gcm/send` should still be used for sending messages imo, and `/gcm/notification` to create the notification key.
 
and I should use send operation. But there is no sample payload for send operation. Can you please give me sample payload for send operation.

 

The follwing works but the notification was only sent to only one device, eventhough I have two devices under same notification key.

 

Post to https://android.googleapis.com/gcm/send

 
Request Details
 
Request Size: 510 

Request Method: POST 

Request Content: {"registration_ids":["APA91bHjVoaAFnfTc2_tRfKNlHLADm9F0H01v2JhYUQdFsW5e15UToV4MklVXOreJ8vx8nmvyCUgXUMW0HnavRrqCqrtJaHsyYFP_bIMG4iagSS9DYkFkobQD8UaNKJUOLV2-v8TemQ38yWGOt7uxaOSZqru13lC-lC4lHR0-BDl-SzX_rOKVwc"],"data":{"quiettime":"false","badge":"9","title":"USAA","alert":"detail","sound":"default"},"notification_key":"APA91bHuyJIMwlz8_e8z6yq5qdPc32z9fAp9EV66EWl0jq_-A1F5-4nMlGH0EwPFpsHuCjhylKipfa4Z4IVagDsCDeNyi6jvbCIGq6iNf8IFLqH1bXH-_PSMjslLSQE15GCxCmZ9nTOX","collapse_key":"AlertMsgSync-4","time_to_live":1} 

That's because it has a registration ID, so it ignored the notification key; but don't bother excluding the registration_ids parameter, it won't work.
 
Please let me know if you managed to get this to work.

John Lee

unread,
Dec 3, 2013, 6:10:41 AM12/3/13
to andro...@googlegroups.com
Hi, K Mak
I also met this issue "HTTP/1.1 401 Unauthorized".
And, I resolved the issue replacing API Key with Brower Key.

Use a browser key if your application is running on a client

Please refer following link :

Best Regards, John
2013년 10월 5일 토요일 오전 3시 21분 6초 UTC+9, K Mak 님의 말:
Reply all
Reply to author
Forward
0 new messages