Java APNS通知未在设备上发送/接收

时间:2017-11-20 11:42:26

标签: java ios apple-push-notifications javaapns

最近开始收到此错误:

2017-11-16 16:14:00,626 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - sendMessage Message(Id=1; Token=********; Payload={****Json Format *****) fromBuffer: true
2017-11-16 16:14:00,716 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Connected new socket 617c3fce[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]]
2017-11-16 16:14:00,716 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Launching Monitoring Thread for socket 617c3fce[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]]
2017-11-16 16:14:00,716 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Made a new connection to APNS
2017-11-16 16:14:00,716 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Started monitoring thread
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Error-response packet 08080000007C
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.Utilities - close 617c3fce[SSL_RSA_WITH_3DES_EDE_CBC_SHA: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]]
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Closed connection cause=INVALID_TOKEN; id=1
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Candidate for removal, message id 1
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Bad message found 1
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - delegate.messageSendFailed, message id 1
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - resending 0 notifications
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Monitoring input stream closed by EOF
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.Utilities - close 617c3fce[SSL_RSA_WITH_3DES_EDE_CBC_SHA: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]]
2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - draining buffer

一些背景知识:

以下是我的代码发送APNS通知的方式:

 String payload = null;
    try {
        ApnsService service = getService(tocCode);

        if (service != null) {

            payload = APNS.newPayload()
                    .sound("default")
                    .alertTitle(dataMap.get("title"))
                    .customFields(dataMap)
                    .alertBody(dataMap.get("message"))
                    .build();

            final Collection<? extends ApnsNotification> push = service.push(deviceids, payload);

            deleteInactiveDevices(service);

        } else {
            logger.error("Could not initialize APNS service );
        }

有时推送通知正在进行并且正在接收其他时间它们不是并且抛出上述错误。任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

遇到同样的问题,但在初始化服务时使用.withSandboxDestination()并且似乎有效(即使使用生产证书)