3

I am playing around with the Google Cloud Messaging sample code given in Android SDK. Both the client and server code works fine. I have installed the GCM client android app in three android devices and when the server is running each of the devices gets registered successfully to the GCM Server. And whenever I try to send message the server broadcasts the messages to all the three devices. But my question is whether we can blacklist any of the device or allow the server to send message to any of the particular device.

Is there any method to restrict the device using the registrationID generated in the server for each devices?

Here is the server code for sending push notification

if (devices.size() == 1) {          
    String registrationId = devices.get(0);
            if(!(registrationId .equalsIgnoreCase("APA91bE61KYmI4Qzn9NKkh6wkHr1ya8FIfGbc_gYJf0_33558IeFnj9j8j4EPRaJeSKJ_CK6_a9FQLt_CapLE4e_mvRaq3hytJalfjTBbkAxbLIdfdXyoxatSrDPmtxSdyaeiRV-Bav-4qOSlURH5mL69Fa9ktX8JFoow")))
            {
                            Message message = new Message.Builder().build();
                            Result result = sender.send(message, registrationId, 5);
                            results = Arrays.asList(result);
            }
  } else {
    // send a multicast message using JSON
    Message message = new Message.Builder().build();
    MulticastResult result = sender.send(message, devices, 5);
    results = result.getResults();
  }
Vishnu Rajan
  • 241
  • 3
  • 9

1 Answers1

3

There is no built-in method to restrict some devices in GCM-Server but you can create your own blackList and send message to the devices other than this list.

You can create your devicesList which does not include registrationIds in the blackList and send multicast message to this list.

Check javadoc for more information about the GCM server-side code here.

Parvin Gasimzade
  • 25,180
  • 8
  • 56
  • 83
  • 1
    hey i also want to send push notification to particular devices and according to u,i can create devicelist to which i want to send push notification..bt my problem is how can i recognize particular regID of particular client(device).. bcz i want to send diff diff push notification to diff diff client ..if u have any idea then plz suggest and guide me..Thanks.. – Kinjal Shah Sep 03 '12 at 11:49