Answer the question
In order to leave comments, you need to log in
Is it possible to send a push notification to a specific user?
There is a task to make push notifications to users on androin applications, the server part on php. The question is, is it possible to make Push notifications to a specific user or are they made to everyone who has installed the application? As I understand it, when installing from google, the client receives a key token by which it is determined who needs to send a notification. How to get this key? is there a hook or something like that? or is it completely different?
Answer the question
In order to leave comments, you need to log in
1. The server must have a system for storing actual tokens of application users.
2. On the client, when registering with GCM, you need to send the received token to the server:
public class RegistrationIntentService extends IntentService {
// ...
@Override
public void onHandleIntent(Intent intent) {
// ...
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
sendTokenToServer(token);
}
// ...
}
You can, an example of the server part is in the official documentation.
As a matter of fact in GCM there are 2 modes of simple sending. One by one and several.
There is not even such a thing as "everyone"
You have a separate GCMid for each user.
You can only break them into groups. This is already a new opportunity.
https://developers.google.com/cloud-messaging/down...
Example for one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question