将通知推送到 IOS 发出代号一

Push Notification to IOS issue CodeName One

我尝试将通知从 java 服务器推送到 IOS 客户端 我有这个错误(代号一台服务器的响应)

{"error":"Failed to send push to APNS: com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake"}

    String GOOGLE_SERVER_KEY = "********************************************";
    HttpsURLConnection connection;
    String url = "https://push.codenameone.com/push/push"; 
    String TOKEN = "******-****-*****-*****-**************";
    String URL_ENCODED_LINK_TO_YOUR_P12_FILE =
        "https://dl.dropboxusercontent.com/*/******************/Certificates.p12";
    String URL_ENCODED_CERTIFICATE_PASSWORD = "******";

    String deviceId =
        "cn1-gcm-*******************************************************";
    String deviceId2 =
        "cn1-ios-***************************************************";
    String MESSAGE_BODY = "This notification  message coming from server";
    try {

        connection = (HttpsURLConnection)new URL(url).openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
        String query =
            "token=" + TOKEN + "&device=" + deviceId + "&device=" +
            deviceId2 + "&type=1&auth=" + GOOGLE_SERVER_KEY +
            "&certPassword=" + URL_ENCODED_CERTIFICATE_PASSWORD +
            "&cert=" + URL_ENCODED_LINK_TO_YOUR_P12_FILE + "&body=" +
            URLEncoder.encode(MESSAGE_BODY, "UTF-8") + "&production=false";
        try {
            OutputStream output = connection.getOutputStream();
            output.write(query.getBytes("UTF-8"));
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("ResponseCode : " + connection.getResponseCode());
        System.out.println("ResponsenMessage : " +
                           connection.getResponseMessage());
        BufferedReader br =new BufferedReader(new InputStreamReader((connection.getInputStream())));

        String output;
        String result = "";
        System.out.println("Output  .... \n");
        while ((output = br.readLine()) != null) {
            System.out.println(output);
            result += output + "\n";
        }

        connection.disconnect();
    } catch (Exception e) {
        e.printStackTrace();
    }

从代号一服务器输出

响应代码:200

响应信息:OK

输出....

{"error":"Failed to send push to APNS: com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake"}

我认为 2195 和 2196 端口在服务器端或客户端被禁用,需要为苹果推送通知启用。

握手异常通常意味着 Codename One 服务器由于安全问题而无法连接。这可能意味着您的 P12 不正确。

您确定您使用了正确的 P12 文件吗?请记住,有 2 个推送证书(不要与 2 个签名证书混淆),并且根据沙箱标志的值只能使用其中一个。

您使用证书向导了吗?