gpt4 book ai didi

java - 使用 Java-PNS 向 iPhone 发送推送通知时出现错误?

转载 作者:行者123 更新时间:2023-12-01 15:20:22 24 4
gpt4 key购买 nike

我正在使用 javaPNS_2.2.jar 文件将推送通知消息发送到 iPhone 设备。

我的代码是:

PushNotificationPayload payload = PushNotificationPayload.complex();

/* Customize the payload */
payload.addAlert("Hello World!");
payload.addCustomDictionary("mykey1", "My Value 1");
payload.addCustomDictionary("mykey2", 2);

/* Push your custom payload */
String keystore = "C:/1.0Eywa_Baba/PushNotificationKey.p12";
String password = "Eywa@12";
boolean production = false;
String devices = "C81DD339-F5C1-529F-BEC4-6C8622BA0BFD";
List<PushedNotification> notifications = Push.payload(payload,
keystore,
password,
production,
devices);

但是,我收到错误:

log4j:WARN No appenders could be found for logger (javapns.notification.Payload).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:105)
at javapns.Push.sendPayload(Push.java:171)
at javapns.Push.payload(Push.java:149)
at com.example.SendMSG.send(SendMSG.java:35)
at com.example.APNDemo1.main(APNDemo1.java:20)
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

是什么导致了这个异常?

最佳答案

将 bcprov-jdk15-140 jar 包含在项目的类路径中。

关于java - 使用 Java-PNS 向 iPhone 发送推送通知时出现错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11012191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com