Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/notnoop/apns/DeliveryError.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public enum DeliveryError {
INVALID_TOPIC_SIZE(6),
INVALID_PAYLOAD_SIZE(7),
INVALID_TOKEN(8),
SHUTDOWN(10),

NONE(255),
UNKNOWN(254);
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/notnoop/apns/internal/ApnsConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ public void run() {
Utilities.close(socket);

int command = bytes[0] & 0xFF;
if (command != 8) {
// A status code of 10 indicates that the APNs server closed the connection,
// The notification identifier in the error response indicates the last notification that was successfully sent.
if (command != 8 && command != 10) {
throw new IOException("Unexpected command byte " + command);
}
int statusCode = bytes[1] & 0xFF;
Expand Down Expand Up @@ -185,8 +187,10 @@ public void run() {
}

if (foundNotification) {
logger.debug("delegate.messageSendFailed, message id {}", notification.getIdentifier());
delegate.messageSendFailed(notification, new ApnsDeliveryErrorException(e));
if (DeliveryError.INVALID_TOKEN == e) {
logger.debug("delegate.messageSendFailed, message id {}", notification.getIdentifier());
delegate.messageSendFailed(notification, new ApnsDeliveryErrorException(e));
}
} else {
cachedNotifications.addAll(tempCache);
int resendSize = tempCache.size();
Expand All @@ -195,8 +199,11 @@ public void run() {
cacheLength = cacheLength + (resendSize / 2);
delegate.cacheLengthExceeded(cacheLength);
}
logger.debug("delegate.messageSendFailed, unknown id");
delegate.messageSendFailed(null, new ApnsDeliveryErrorException(e));

if (DeliveryError.INVALID_TOKEN == e) {
logger.debug("delegate.messageSendFailed, unknown id");
delegate.messageSendFailed(null, new ApnsDeliveryErrorException(e));
}
}

int resendSize = 0;
Expand Down