以下只是服务器端的操作步骤:
1.下载JavaPNs的库文件JavaPNS_2.2.jar
2.下载Java依赖的jar bcprov-jdk15on-150.jar和log4j-1.2.17.jar
3,获得.p12文件和设备的Token值
4.测试类
public class TestMain {
public static void main(String[] args){
List<Device> devices=new ArrayList<Device>();
Device device = new BasicDevice();
device.setToken("");
devices.add(device);
Device device2 = new BasicDevice();
device2.setToken("");
devices.add(device2);
String message="1234567890!";
String keystore="D:/***.p12";(.p12文件的路径)
String password="";
try {
PushedNotifications notifications=Push.alert(message, keystore, password, false, devices);
PushedNotifications fails=notifications.getFailedNotifications();
PushedNotifications success=notifications.getSuccessfulNotifications();
System.out.println("fails :" + fails.isEmpty());
System.out.println("success:" +success.isEmpty());
} catch (CommunicationException e) {
e.printStackTrace();
} catch (KeystoreException e) {
e.printStackTrace();
}
}
}