javapns.notification.ResponsePacket Java Examples

The following examples show how to use javapns.notification.ResponsePacket. 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: Worker.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
private void processPushedNotifications(String taskName, PushedNotifications notifications) {
  List<String> invalidTokens = new ArrayList<String>();

  for (PushedNotification notification : notifications) {

    if (!notification.isSuccessful()) {
      log.log(Level.WARNING,
          "Notification to device " + notification.getDevice().getToken() + 
          " from task " + taskName + " wasn't successful.",
          notification.getException());

      // Check if APNS returned an error-response packet.
      ResponsePacket errorResponse = notification.getResponse();
      if (errorResponse != null) {
        if (errorResponse.getStatus() == 8) {
          String invalidToken = notification.getDevice().getToken();
          invalidTokens.add(invalidToken);
        }
        log.warning("Error response packet: " + errorResponse.getMessage());
      }
    }

    if (invalidTokens.size() > 0) {
      Utility.enqueueRemovingDeviceTokens(invalidTokens);
    }
  }
}
 
Example #2
Source File: Worker.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
private void processPushedNotifications(String taskName, PushedNotifications notifications) {
  List<String> invalidTokens = new ArrayList<String>();

  for (PushedNotification notification : notifications) {

    if (!notification.isSuccessful()) {
      log.log(Level.WARNING,
          "Notification to device " + notification.getDevice().getToken() + 
          " from task " + taskName + " wasn't successful.",
          notification.getException());

      // Check if APNS returned an error-response packet.
      ResponsePacket errorResponse = notification.getResponse();
      if (errorResponse != null) {
        if (errorResponse.getStatus() == 8) {
          String invalidToken = notification.getDevice().getToken();
          invalidTokens.add(invalidToken);
        }
        log.warning("Error response packet: " + errorResponse.getMessage());
      }
    }

    if (invalidTokens.size() > 0) {
      Utility.enqueueRemovingDeviceTokens(invalidTokens);
    }
  }
}
 
Example #3
Source File: PushNotificationWorker.java    From solutions-ios-push-notification-sample-backend-java with Apache License 2.0 5 votes vote down vote up
private void processPushedNotifications(String taskName, PushedNotifications notifications) {
  List<String> invalidTokens = new ArrayList<String>();

  for (PushedNotification notification : notifications) {

    if (!notification.isSuccessful()) {
      log.log(Level.WARNING,
          "Notification to device " + notification.getDevice().getToken() +
          " from task " + taskName + " wasn't successful.",
          notification.getException());

      // Check if APNS returned an error-response packet.
      ResponsePacket errorResponse = notification.getResponse();
      if (errorResponse != null) {
        if (errorResponse.getStatus() == 8) {
          String invalidToken = notification.getDevice().getToken();
          invalidTokens.add(invalidToken);
        }
        log.warning("Error response packet: " + errorResponse.getMessage());
      }
    }

    if (invalidTokens.size() > 0) {
      PushNotificationUtility.enqueueRemovingDeviceTokens(invalidTokens);
    }
  }
}