Package com.google.android.gcm.server

Examples of com.google.android.gcm.server.Message$Builder


    for (Entry<String, String> entry : gcmMessage.getParameters().entrySet()) {
      if (entry.getValue() != null) {
        messageBuilder.addData(entry.getKey(), entry.getValue());
      }
    }
    Message message = messageBuilder.build();
    PushResponse pushResponse = new PushResponse();
    try {
      MulticastResult multicastResult = sender.send(message, Lists.newArrayList(registrationIds), 10);
     
      // analyze the results
View Full Code Here


    taskDone(resp);
    return;
  }

  private Message createMessage() {
    Message message = new Message.Builder().addData("ghgg", "nnnnn").build();
    return message;
  }
View Full Code Here

    return message;
  }

  private void sendSingleMessage(String regId, HttpServletResponse resp) {
    logger.info("Sending message to device " + regId);
    Message message = createMessage();
    Result result;
    try {
      result = sender.sendNoRetry(message, regId);
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Exception posting " + message, e);
View Full Code Here

  private void sendMulticastMessage(String multicastKey,
      HttpServletResponse resp) {
    // Recover registration ids from datastore
    List<String> regIds = Datastore.getMulticast(multicastKey);
    Message message = createMessage();
    MulticastResult multicastResult;
    try {
      multicastResult = sender.sendNoRetry(message, regIds);
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Exception posting " + message, e);
View Full Code Here

    return retObj;
  }

  private MulticastResult sendMessageToDevice(String apiKey, List<String> devices, String title, String message) {
    Sender sender = new Sender(apiKey);
    Message gcmMessage = new Message.Builder().addData("title", title).addData("message", message).build();
    MulticastResult result = null;
    try {
      result = sender.send(gcmMessage, devices, 3);
    } catch (IOException e) {
      //e.printStackTrace();
View Full Code Here

    if (null != extraMap) {
      for (String key : extraMap.keySet()) {
        builder.addData(key, extraMap.get(key));
      }
    }
    Message gcmMessage = builder.build();
    MulticastResult result = null;
    try {
      result = sender.send(gcmMessage, devices, 3);
    } catch (IOException e) {
      // e.printStackTrace();
View Full Code Here

   */

  private void sendMulticastMessage(String multicastKey, String serverStatusKey, HttpServletResponse resp) {
    // Recover registration ids from datastore
    List<String> regIds = Datastore.getMulticast(multicastKey);
    Message message = createMessage(serverStatusKey);
   
    MulticastResult multicastResult;
    try {
      multicastResult = sender.sendNoRetry(message, regIds);
    } catch (IOException e) {
View Full Code Here

    if (Logger.isDebugEnabled()) Logger.debug("time_to_live: " + time_to_live);

    if (Logger.isDebugEnabled()) Logger.debug("Custom Data: " + customData.toString());

    Sender sender = new Sender(apikey);
    Message msg = new Message.Builder().addData("message", message)
        .addData("custom", customData.toString())
        .collapseKey(collapse_key.toString())
        .timeToLive(time_to_live)
        .build();
View Full Code Here

      isInit = true;
    }
  }

  public static void validateApiKey(String apikey) throws MalformedURLException, IOException, PushInvalidApiKeyException{
    Message message = new Message.Builder().addData("message", "validateAPIKEY")
        .build();
    Sender sender = new Sender(apikey);

    List<String> deviceid = new ArrayList<String>();
    deviceid.add("ABC");

    Map<Object, Object> jsonRequest = new HashMap<Object, Object>();
    jsonRequest.put(JSON_REGISTRATION_IDS, deviceid);
    Map<String, String> payload = message.getData();
    if (!payload.isEmpty()) {
      jsonRequest.put(JSON_PAYLOAD, payload);
    }
    String requestBody = JSONValue.toJSONString(jsonRequest);
View Full Code Here

        for (String key : keys) {
            // GCM needs stringified values:
            gcmBuilder.addData(key, "" + pushMessage.getData().get(key));
        }

        Message gcmMessage = gcmBuilder.build();

        // send it out.....
        try {
            logger.log(Level.FINE, "Sending transformed GCM payload: " + gcmMessage);
View Full Code Here

TOP

Related Classes of com.google.android.gcm.server.Message$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.