When I try to execute an apple push notification on the server I get the following error:
com.notnoop.exceptions.ApnsDeliveryErrorException: Failed to deliver notification with error code 8
My server is a Java application. It is strange that the same server WAR file works OK locally (notifications are sent), but it does not work (with error above) when I deploy it to remote server (RedHat openshift.com).
Here is what I do:
- In Xcode I archive my application and export it for Ad Hoc distribution using Distribution Provisioning profile. The profile contains "aps-environment production" entitlement.
- In Apple Developer center, I download the APNs production iOS certificate, import it in my iMac Keychain and export a p12 file.
- I deploy the .p12 file to my server, where I use https://github.com/notnoop/java-apns library to execute apple push notifications. The library is initialized like this:
APNS.newService().withCert(certificateInputStream,"password").withProductionDestination().withDelegate(this).build();
- When run, the client application successfully registeres for push notifications and receives a token.
- When the server tries to execute a push notification, an exception is thrown: com.notnoop.exceptions.ApnsDeliveryErrorException: Failed to deliver notification with error code 8
Can you help? What could be the reason that the same setup works on a local but fail on a remote server?
It appeared to be another error. The server contained old deployment (war) file, which was still pointing to the sandbox APNS environment. After I redeployed manually, the problem is gone.