javapns-jdk16
javapns-jdk16 copied to clipboard
java.lang.StringIndexOutOfBoundsException: String index out of range: 64
This harmful implementation gives OOB exception on short token like simulator
generated by iOS IDE
`
public String toString() {
StringBuilder msg = new StringBuilder();
msg.append("[" + this.identifier + "]");
msg.append(this.transmissionCompleted?" transmitted " + this.payload + " on " + this.getLatestTransmissionAttempt():" not transmitted");
msg.append(" to token " + this.device.getToken().substring(0, 5) + ".." + this.device.getToken().substring(59, 64));
if(this.response != null) {
msg.append(" " + this.response.getMessage());
}
if(this.exception != null) {
msg.append(" " + this.exception);
}
return msg.toString();
}
`
Sorry, but could not understand your issue. My understanding is that APNS does not provide a token to the iOS simulator, that is why you can only test push notifications using a real device. Please can you provide more info?
My backend received simulator
as a token value and the code broke in a place I would never expect. Even if token is not correct it's not the reason why toString
method should fail because naturally people use it for logging outside try-catch structure and it may brake a lot...