I’ve developed an app which worked fine with developer profile. However, I am now in production and the PUSH notification is not working anymore.
I’m using the java-apns from notnoop
The certificate is the correct one (as I tried it in my local laptop).
However, it’s not working in my server. I’m getting the following error:
com.notnoop.exceptions.NetworkIOException: java.net.SocketException: Socket closed
The code I’m using is the following:
try{
//Abrimos el servicio con el certificado
ApnsService service =APNS.newService()
.withCert("cert.p12", "password")
.withProductionDestination()
.build();
String payload="";
payload = APNS.newPayload().sound("default").badge(1).localizedKey("ShoutPushStringWithData").localizedArguments(pUserName, pMessage).build();
String token = pPushURI;
service.push(token, payload);
} catch(RuntimeIOException | InvalidSSLConfig | NetworkIOException e){
WebServiceLogger.getInstance().log(Level.INFO, "[ERROR PUSH]: "+ e);
}
What am I doing wrong? How could I fix it?
Thanks,
Ibai
Finally solved. It was impossible to get this work with java-apns, I don’t know why.
I have decided to use javapns and it’s been fixed although it haven’t been easy.
An important point is that the Certificate.p12 must be only the one exported just from the Apple Production iOS Push Services and not the one exported from both Distribution and Production iOS Push Services as I read in other posts.
Good luck with this!