Send a GCM message to a specific user

In my application, I want to send a notification to a specific user regardless of the device. The user can enter the application from any device.

This is the first time I use GCM. I read a document that says that when a device is registered on the GCM server, the device sends this unique identifier to the server and then saves this value for sending messages.

Then, how to send a notification to a specific user when entering the application from different devices?

+8
android google-cloud-messaging
source share
1 answer

This unique identifier (aka Registration ID) is unique based on the application / device, so if this user logs into the GCM services on another device, he will generate another registration identifier.

An identifier issued by GCM servers to an Android application that allows it to receive messages. After the Android application has a registration identifier , it sends it to a third-party application server , which uses it to identify each device registered to receive messages for this Android application. In other words, the registration identifier is tied to a specific Android application running on a specific device.

When you say a log, I think you are talking on your server, right?

I ask this because GCM services require a Google account if your application targets up to 4 API versions.

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

If GCM discovers a google account on the device, it can access this service. If the GCM does not detect the account, it returns an ACCOUNT_MISSING error.

Therefore, it may happen that access to GCM services with a google account is not yours if you use another device that was previously registered with a Google account.

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

Updated:

You will need to send a notification to all registration identifiers belonging to the user connected to your server. You cannot know which device the user is using if you are using multiple servers on your server.

You can use multicast

Link: GCM

+6
source share

All Articles