G
G
GPK19292016-01-16 18:35:28
PHP
GPK1929, 2016-01-16 18:35:28

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

3 answer(s)
A
Andrey Sedyshev, 2016-01-16
@GPK1929

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);
    }

    // ...
}

Link to documentation: https://developers.google.com/cloud-messaging/andr...
Link to implementation of this in Goolge's sample app: https://github.com/googlesamples/google-services/b.. .

F
FoxInSox, 2016-01-16
@FoxInSox

You can, an example of the server part is in the official documentation.

O
Oleg Karnaukhov, 2016-01-16
@BupycNet

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 question

Ask a Question

731 491 924 answers to any question