如何发送没有ssl证书的android推送通知
答
查看链接。我希望它能帮助你。你应该禁用你的服务器SSL然后发送推送通知。使用下面的链接进行参考。 1)代码为客户端2)添加此代码的服务器。
1)http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/ 2)http://www.nakov.com/blog/2009/07/16/disable-certificate-validation-in-java-ssl-connections/
public static void main(String[] args) throws Exception {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
};
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
// Create all-trusting host name verifier
HostnameVerifier allHostsValid = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
URL url = new URL("https://www.nakov.com:2083/");
URLConnection con = url.openConnection();
Reader reader = new InputStreamReader(con.getInputStream());
while (true) {
int ch = reader.read();
if (ch==-1) {
break;
}
System.out.print((char)ch);
}
}
+0
等待我只是指它。 – 2015-02-25 06:27:54
:按我在机器人GCM关注用于推送通知,这是可能的,而不具有SSL证书。 – 2015-02-23 06:50:57
我尝试GCM,但它给出错误消息。看我以前的帖子。 http://stackoverflow.com/questions/28647660/ssl-handshake-exception-in-android-gcm-server这里是链接。 – 2015-02-23 06:54:17
如果你知道发送任何链接或示例代码@Born赢得 – 2015-02-23 06:57:02