Django Push Notifications With Device Custom Model
I have a question about Django push notifications. In my Django project I have my model for mobile device. In this model I have all device info like token (used to send a push noti
Solution 1:
Having done all that work, you probably don't need a library, you can send your GCM messages by making simple HTTP posts to the GCM server it's only a few lines of code. If you are using the python requests library already for http stuff, it's practically a one liner.
requests.post( 'https://gcm-http.googleapis.com/gcm/send',
data = json.dumps(message),
headers = {'Authorization': auth_token,'Content-Type': 'application/json'})
Where message is your GCM message which follows the guidelines on GCM docs and looks like this.
{ "notification": {
"title": "Portugal vs. Denmark",
"text": "5 to 1"
},
"to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."
}
auth_token
will look like 'key=YOUR_GCM_KEY'
Lastly if you are really keen to use a more complex library but want to preserve your models, consider Python GCM which can be plugged into django quite easily.
Post a Comment for "Django Push Notifications With Device Custom Model"