ResponsePacket theErrorResponse = pushNotification.getResponse();我正在使用 javapns2.2 并试图从苹果的增强通知格式中捕获错误响应数据包。当我发送推送通知(例如使用无效令牌)时,代码
Exception theProblem = pushedNotification.getException();
theProblem.printStackTrace();
向控制台输出一些错误,但是
ResponsePacket theErrorResponse = pushedNotification.getResponse();
if (theErrorResponse != null && theErrorResponse.isErrorResponsePacket()) {
System.out.println(theErrorResponse.getMessage());
System.out.println(theErrorResponse.getStatus());
}
总是返回null。如何使用 getResponse() 获取状态码?
这是我的代码的一部分:
List<PushedNotification> notifications = Push.payload(payload, keystore, password, production, devices);
for (PushedNotification pushedNotification : notifications) {
if(pushedNotification.isSuccessful())
{
System.out.println(pushedNotification.getDevice().getToken());
}
else
{
System.out.println(pushedNotification.getDevice().getToken());
Exception theProblem = pushedNotification.getException();
theProblem.printStackTrace();
ResponsePacket theErrorResponse = pushedNotification.getResponse();
if (theErrorResponse != null && theErrorResponse.isErrorResponsePacket()) {
System.out.println(theErrorResponse.getMessage());
System.out.println(theErrorResponse.getStatus());
}
}
}
谢谢您的帮助