private static int sendPush(String text, String targetOS, int ttl, APIClient apiClient)
      throws IOException {
    Alert<String> alert = new Alert<String>(text);
    // remove this line if you just want to send it to all registered
    // devices
    alert.setTargetOS(targetOS);
    // do not keep the push more than 2 minutes if device is not
    // available
    alert.setTTL(ttl);

    // Uncomment this line if you prefer to implicitly create tags
    // if there are tags passed on this alert that do not
    // exist on the project
    // alert.setImplicitTagCreation(true);

    List<String> tags = new ArrayList<String>();
    // send push to all registered devices
    tags.add(Alert.ALL_PUSH_TAG);
    alert.setTags(tags);

    // make this push 'normal' priority, meaning the gateway (GCM, APNS)
    // could delay it if device is sleeping
    alert.setNotificationPriority(Alert.Priority.normal);

    return apiClient.publish(alert);
  }
  private static Alert<String> buildScheduledPush(
      String text, Date scheduledAt, String targetOS, int ttl) {
    Alert<String> alert = new Alert<String>(text);
    // remove this line if you just want to send it to all registered
    // devices
    alert.setTargetOS(targetOS);
    // do not keep the push more than 2 minutes if device is not
    // available
    alert.setTTL(ttl);

    List<String> tags = new ArrayList<String>();
    // send push to all registered devices
    tags.add("test-channel");
    tags.add("dev-channel");
    alert.setTags(tags, Alert.TAG_MATCH_OP_AND);

    // make this push 'normal' priority, meaning the gateway (GCM, APNS)
    // could delay it if device is sleeping
    alert.setNotificationPriority(Alert.Priority.normal);

    alert.setScheduledAt(scheduledAt);

    return alert;
  }