我正在测试ios push in java,它显示成功但没有在设备上接收。下面是我的java代码。我已经拿走了APNS证书和令牌。 ' messageSent'代表正在展示 已发送消息消息(Id = 1;令牌= 3998989 ......;有效负载= {" aps":{"警告":"您有新消息!" })重新发送:false
public void sendEnhancedPush() {
final ApnsDelegate delegate = new ApnsDelegate() {
public void messageSent(final ApnsNotification message,
final boolean resent) {
System.out.println("Sent message " + message + " Resent: "
+ resent);
}
public void messageSendFailed(final ApnsNotification message,
final Throwable e) {
System.out.println("Failed message " + message);
}
public void connectionClosed(final DeliveryError e,
final int messageIdentifier) {
System.out.println("Closed connection: " + messageIdentifier
+ "\n deliveryError " + e.toString());
}
public void cacheLengthExceeded(final int newCacheLength) {
System.out.println("cacheLengthExceeded " + newCacheLength);
}
public void notificationsResent(final int resendCount) {
System.out.println("notificationResent " + resendCount);
}
};
service = APNS.newService()
.withCert(certificate_file, certificate_pass)
.withProductionDestination().withDelegate(delegate).build();
String payload = APNS.newPayload().alertBody("You have new message!")
.build();
System.out.println("sending push");
service.push(token, payload);
Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
Date inactiveAsOf = inactiveDevices.get(deviceToken);
System.out.println("inactiveAsOf, " + inactiveAsOf);
}
}
提前致谢。