Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send GCM message to Particular user

In my application i want to send notification to a particular user irrespective of the device. User can log into the application from any device.

This is the first time i am using GCM. I read the document it says that when the device registered with the GCM server, the device send that unique ID to the server, and then save that value for sending messages.

Then how to send notification to a particular user when he log into the application from different devices?

like image 863
Sunny Avatar asked May 27 '13 11:05

Sunny


1 Answers

This unique ID (aka registration ID) is unique given an app/device, so if this user logs to GCM services on another device it will generate another registration ID.

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.

When you say log I think you are reffering to your server, right?

I ask it because GCM services requires a Google account if your app is targetting pre 4 API versions.

A Google account is not a requirement on devices running Android 4.0.4 or higher.

If GCM detects a google account on the device it can acces to the service. If GCM does not detect the account it returns an ACCOUNT_MISSING error.

So it could happen to acces the GCM services with a google account that is not yours if you are using another device which was previously registered with a Google account.

But if the important account is one managed by your server then I think it does not really matter.

Updated:

You will have to send the notification to all registrationID belonging to the user connected to your server. You can not know which device is the user currently using if you mantain more than one at your server.

You can use multicast

Reference:GCM

like image 81
AlexBcn Avatar answered Oct 11 '22 22:10

AlexBcn