JavaPN 有一个标志(在其方法之一中),用于确定它们是尝试连接到沙箱还是生产推送环境。它与您提供给它的证书无关。
例如,在以下方法中,您需要提供true
连接到生产和false
连接到沙盒。
/**
* 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);
}