Reputation: 218
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.
Upvotes: 3
Views: 4999
Reputation: 773
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" : {
...
},
}
Upvotes: 4
Reputation: 1728
Quoted from Android docs, a RegId
is:
An ID issued by the GCM servers to the Android application that allows it to receive messages. Once the Android application has the registration ID, it sends it to the 3rd-party application server, which uses it to identify each device that has registered to receive messages for a given Android application. In other words, a registration ID is tied to a particular Android application running on a particular device.
So a RegId
is Application and User specific.
For storing, you can send a Post after the registration of GCM complete. Use the sample apps provided by Google and you will get some clues.
Upvotes: 0
Reputation: 20563
You can send multicase messages to upto 1000 users at once. See Google's guide:
http://developer.android.com/training/cloudsync/gcm.html
Apart from that, You can make an array of all registered users and send messages to all of them individually one-by-one.
Upvotes: 0
Reputation: 513
Yes registration ID is unique to particular User for particular application. You can create your databse and store them all
Upvotes: 0