public PushedNotifications sendPayload(Payload payload, String[] deviceTokens)
      throws CommunicationException, KeystoreException {
    PushedNotifications notifications = new PushedNotifications();

    if (payload == null) {
      return notifications;
    }

    try {
      if (!isConnected) {
        initializeConnection();
      }

      List<Device> deviceList = Devices.asDevices(deviceTokens);
      notifications.setMaxRetained(deviceList.size());
      for (Device device : deviceList) {
        try {
          BasicDevice.validateTokenFormat(device.getToken());
          PushedNotification notification = pushManager.sendNotification(device, payload, false);
          notifications.add(notification);
        } catch (InvalidDeviceTokenFormatException e) {
          notifications.add(new PushedNotification(device, payload, e));
        }
      }
    } catch (CommunicationException e) {
      stopConnection();
      throw e;
    }
    return notifications;
  }