My iOS notification server is using DEV SSL Certificate but is connecting to gateway.push.apple.com?

StackOverflow https://stackoverflow.com/questions/19710962

سؤال

I am using a DEV SSL Certificate but strangely my notification server is connecting to "gateway.push.apple.com" instead of "gateway.sandbox.push.apple.com".

In Keychain Access, the certificate is called "Apple Development IOS Push Services:…" so I am pretty sure it's for development. I created my .p12 file from that and deployed to my notification server.

This was actually working fine before; however, my certificate expired so I had to create a new one via the Provisioning Center. Then I ran into this strange issue.

My notification server is written in Java, using javapns API. I tried creating the .p12 again and also restart my notification server but no luck...

Has anyone seen this issue before? Thanks in advance.

هل كانت مفيدة؟

المحلول

JavaPNs has a flag (in one of its methods) that determines whether they attempt to connect to the Sandbox or Production push env. It has nothing to do with the certificate you supply to it.

For example, in the following method you need to supply true to connect to Production and false to connect to Sandbox.

/**
 * Push a preformatted payload to a list of devices.
 * 
 * @param payload a simple or complex payload to push.
 * @param keystore a keystore containing your private key and the certificate signed by Apple ({@link java.io.File}, {@link java.io.InputStream}, byte[], {@link java.security.KeyStore} or {@link java.lang.String} for a file path)
 * @param password the keystore's password.
 * @param production true to use Apple's production servers, false to use the sandbox servers.
 * @param devices a list or an array of tokens or devices: {@link java.lang.String String[]}, {@link java.util.List}<{@link java.lang.String}>, {@link javapns.devices.Device Device[]}, {@link java.util.List}<{@link javapns.devices.Device}>, {@link java.lang.String} or {@link javapns.devices.Device}
 * @return a list of pushed notifications, each with details on transmission results and error (if any)
 * @throws KeystoreException thrown if an error occurs when loading the keystore
 * @throws CommunicationException thrown if an unrecoverable error occurs while trying to communicate with Apple servers
 */
public static PushedNotifications payload(Payload payload, Object keystore, String password, boolean production, Object devices) throws CommunicationException, KeystoreException {
    return sendPayload(payload, keystore, password, production, devices);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top