コード例 #1
0
  public void sendBroadCast(Lead lead) {
    if (getActivePushConfig() != null) {
      UnifiedMessage unifiedMessage =
          new UnifiedMessage.Builder()
              .pushApplicationId(getActivePushConfig().getPushApplicationId())
              .masterSecret(getActivePushConfig().getMasterSecret())
              .simplePush("version=" + broadcastVersion++)
              .attribute("id", lead.getId().toString())
              .attribute("messageType", "pushed_lead")
              .attribute("name", lead.getName())
              .attribute("location", lead.getLocation())
              .attribute("phone", lead.getPhoneNumber())
              .attribute("messageType", "accepted_lead")
              .sound("default")
              .alert("A new lead has been accepted")
              .build();

      javaSender.broadcast(unifiedMessage);
    } else {
      logger.severe("not PushConfig configured, can not send message");
    }
  }
コード例 #2
0
  public void sendLeads(List<String> users, Lead lead) {
    if (getActivePushConfig() != null) {
      Map categories = new HashMap();
      categories.put("lead", "version=" + leadVersion++); // TODO manage the version properly
      UnifiedMessage unifiedMessage =
          new UnifiedMessage.Builder()
              .pushApplicationId(getActivePushConfig().getPushApplicationId())
              .masterSecret(getActivePushConfig().getMasterSecret())
              .aliases(users)
              .simplePush(categories)
              .attribute("id", lead.getId().toString())
              .attribute("messageType", "pushed_lead")
              .attribute("name", lead.getName())
              .attribute("location", lead.getLocation())
              .attribute("phone", lead.getPhoneNumber())
              .sound("default")
              .alert("A new lead has been created")
              .build();

      javaSender.sendTo(unifiedMessage);
    } else {
      logger.severe("not PushConfig configured, can not send message");
    }
  }