T
T
tadej2016-01-15 16:33:36
Django
tadej, 2016-01-15 16:33:36

How to write a server to send push messages using the django_push_notifications library?

Who can intelligibly explain the work of this library, otherwise I would have understood, but I feel that I am missing something.
I'm especially interested in working with registration_id and device_id. The service should work through GCM. Yeah, I registered an application there. And here's where I get stuck.
The server receives
url(r'^push/(?P[0-9]+)/$', push, name='push-message'), + POST
Function:
def push(request, **kwargs) :
devices = GCMDevice.objects.filter(user=kwargs['cid']).all()
message = request.POST.get("message_text") or 'Test message'
devices.send_message(message)
Server response:
HTTP Error 400: Bad Request

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Karnaukhov, 2016-01-15
@BupycNet

Let's abstract from the library and figure out where and what you are sending.
You need to send a POST request to https://gcm-http.googleapis.com/gcm/send
with a JSON array and your key in the header.
If you get 400, then you have, for example, the wrong key is being transmitted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question