I followed some demo's and its working fine in my mobile. But i have some questions. Is Registration Id is unique for application or user? If it is unique for user then how to save multiple regID's in server(dot net). Please give me some guidance.
If it is unique for user then how to save multiple regID's in server(dot net). Please give me some guidance.
When the device registered with the GCM server, the device MUST send that unique ID to your server, and then you save that value for sending messages.
How to send push notifications to multiple users using GCM?
You create message with a format. For multiple IDs, just fill the registration_ids key with your user IDs in the form of array object
Example in python:
ids=[]
query= // get all user record from database
for q in query:
ids.append(q.registration_id)
// some code
jsonmessage=json.dumps({
"registration_ids":ids,
"data":{
"message":message,
"time":datetime.datetime.today().isoformat(),
"sender":sender
}
})
conn.send(jsonmessage)
That will look like this:
Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
{
"registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...", "second_id", "third_id"],
"data" : {
...
},
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With