参考 Java服务端向苹果APNS推送消息, 请关注之前的文章 :http://blog.youkuaiyun.com/qq_37022150/article/details/73991913
不废话,请直接看代码,向所有设备推送消息,注释非常的详细:
public class AndroidPushMsgToAll {
public static void main(String[] args)
throws PushClientException,PushServerException {
// 1. get apiKey and secretKey from developer console
// 从百度推送开发者控制台获取apiKey与 secretKey;
String apiKey = "WKqKYQyAhOLg2L4QlcwiWbAg";
String secretKey = "gSdkkKDkP397up4Kfmp7HGCuL7RoimQv";
// 创建PushKeyPair对象,使用到apiKey与secretKey;
PushKeyPair pair = new PushKeyPair(apiKey, secretKey);
// 2. build a BaidupushCl