您的位置:首页 > 编程语言 > Java开发

使用JavaPns向APNs推送通知

2014-05-14 19:36 232 查看
以下只是服务器端的操作步骤:

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();

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: