javapns.communication.exceptions.CommunicationException Java Examples

The following examples show how to use javapns.communication.exceptions.CommunicationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Sender.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
private void initializeConnection() throws KeystoreException, CommunicationException {
  AppleNotificationServer server = new AppleNotificationServerBasicImpl(
      keystore, password, production);

  pushManager.initializeConnection(server);
  isConnected = true;
}
 
Example #2
Source File: Sender.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Sends an alert notification to a list of devices.
 *
 * @param alertMessage alert to be sent as a push notification
 * @param deviceTokens the list of tokens for devices to which the notifications should be sent 
 * @return a list of pushed notifications that contain details on transmission results.
 * @throws javapns.communication.exceptions.CommunicationException thrown if an error occurred while communicating with the target
 *         server even after a few retries.
 * @throws javapns.communication.exceptions.KeystoreException thrown if an error occurs with using the certificate.
 */
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
    throws CommunicationException, KeystoreException {

  log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
      + " devices started at " + dateFormat.format(new Date()) + ".");
  PushedNotifications notifications =
      sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);

  log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
      + " devices completed at " + dateFormat.format(new Date()) + ".");

  return notifications;
}
 
Example #3
Source File: Sender.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
private void initializeConnection() throws KeystoreException, CommunicationException {
  AppleNotificationServer server = new AppleNotificationServerBasicImpl(
      keystore, password, production);

  pushManager.initializeConnection(server);
  isConnected = true;
}
 
Example #4
Source File: Sender.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
/**
 * Sends an alert notification to a list of devices.
 *
 * @param alertMessage alert to be sent as a push notification
 * @param deviceTokens the list of tokens for devices to which the notifications should be sent 
 * @return a list of pushed notifications that contain details on transmission results.
 * @throws CommunicationException thrown if an error occurred while communicating with the target
 *         server even after a few retries.
 * @throws KeystoreException thrown if an error occurs with using the certificate.
 */
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
    throws CommunicationException, KeystoreException {

  log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
      + " devices started at " + dateFormat.format(new Date()) + ".");
  PushedNotifications notifications =
      sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);

  log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
      + " devices completed at " + dateFormat.format(new Date()) + ".");

  return notifications;
}
 
Example #5
Source File: ConnectionToAppleServer.java    From javapns-jdk16 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create a SSLSocket which will be used to send data to Apple
 * @return the SSLSocket
 * @throws KeystoreException 
 * @throws CommunicationException 
 */
public SSLSocket getSSLSocket() throws KeystoreException, CommunicationException {
	SSLSocketFactory socketFactory = getSSLSocketFactory();
	logger.debug("Creating SSLSocket to " + getServerHost() + ":" + getServerPort());

	try {
		if (ProxyManager.isUsingProxy(server)) {
			return tunnelThroughProxy(socketFactory);
		} else {
			return (SSLSocket) socketFactory.createSocket(getServerHost(), getServerPort());
		}
	} catch (Exception e) {
		throw new CommunicationException("Communication exception: " + e, e);
	}
}
 
Example #6
Source File: PushNotificationSender.java    From solutions-ios-push-notification-sample-backend-java with Apache License 2.0 5 votes vote down vote up
private void initializeConnection() throws KeystoreException, CommunicationException {
  AppleNotificationServer server =
          new AppleNotificationServerBasicImpl(keystore, password, production);

  pushManager.initializeConnection(server);
  isConnected = true;
}
 
Example #7
Source File: PushNotificationSender.java    From solutions-ios-push-notification-sample-backend-java with Apache License 2.0 5 votes vote down vote up
/**
 * Sends an alert notification to a list of devices.
 *
 * @param alertMessage alert to be sent as a push notification
 * @param deviceTokens the list of tokens for devices to which the notifications should be sent
 * @return a list of pushed notifications that contain details on transmission results.
 * @throws CommunicationException thrown if an error occurred while communicating with the target
 *         server even after a few retries.
 * @throws KeystoreException thrown if an error occurs with using the certificate.
 */
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
    throws CommunicationException, KeystoreException {

  log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
      + " devices started at " + dateFormat.format(new Date()) + ".");
  PushedNotifications notifications =
      sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);

  log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
      + " devices completed at " + dateFormat.format(new Date()) + ".");

  return notifications;
}
 
Example #8
Source File: Sender.java    From io2014-codelabs with Apache License 2.0 2 votes vote down vote up
/**
 * Stop connection and closes the socket
 *
 * @throws javapns.communication.exceptions.CommunicationException thrown if an error occurred while communicating with the target
 *         server even after a few retries.
 * @throws javapns.communication.exceptions.KeystoreException thrown if an error occurs with using the certificate.
 */
public void stopConnection() throws CommunicationException, KeystoreException {
  pushManager.stopConnection();
  isConnected = false;
}
 
Example #9
Source File: Sender.java    From solutions-mobile-backend-starter-java with Apache License 2.0 2 votes vote down vote up
/**
 * Stop connection and closes the socket
 *
 * @throws CommunicationException thrown if an error occurred while communicating with the target
 *         server even after a few retries.
 * @throws KeystoreException thrown if an error occurs with using the certificate.
 */
public void stopConnection() throws CommunicationException, KeystoreException {
  pushManager.stopConnection();
  isConnected = false;
}
 
Example #10
Source File: PushNotificationSender.java    From solutions-ios-push-notification-sample-backend-java with Apache License 2.0 2 votes vote down vote up
/**
 * Stop connection and closes the socket
 *
 * @throws CommunicationException thrown if an error occurred while communicating with the target
 *         server even after a few retries.
 * @throws KeystoreException thrown if an error occurs with using the certificate.
 */
public void stopConnection() throws CommunicationException, KeystoreException {
  pushManager.stopConnection();
  isConnected = false;
}