相关疑难解决方法(0)

通过Java使用Apple推送通知服务

我试图实现一个Java程序,它将Apple推送通知发送到iPhone客户端应用程序...找到以下库:Java APN

提供者代码:

创建以下代码(来自Javapns)以在我的应用程序中使用:

try {
    PayLoad payLoad = new PayLoad();

    payLoad.addAlert("My alert message");
    payLoad.addBadge(45);
    payLoad.addSound("default");

    PushNotificationManager pushManager = PushNotificationManager.getInstance();
    pushManager.addDevice("iPhone", "f4201f5d8278fe39545349d0868a24a3b60ed732");
    log.warn("Initializing connectiong with APNS...");

    // Connect to APNs
    pushManager.initializeConnection(HOST, PORT, 
                                 "/etc/Certificates.p12", "password", 
    SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);

    Device client = pushManager.getDevice("Lambo");

    // Send Push
    log.warn("Sending push notification...");
    PushNotificationManager.getInstance().sendNotification(client, payLoad);
 }
 catch (Exception e) {
    throw new ApnsPushNotificationException("Unable to send push " + e);
 }
Run Code Online (Sandbox Code Playgroud)

当我运行这个应用程序时(你可以通过Log4j语句看到),没有例外情况发生:

  WARN  [MyCode] Initializing connectiong with APNS...
  WARN  [MyCode] Sending push notification...
Run Code Online (Sandbox Code Playgroud)

但我的客户端应用程序没有收到任何通知!

IDPP注册流程:

此外,在iPhone开发人员计划门户(IDPP)上执行了以下操作:

  • 创建了基于APNS的SSL证书和密钥

  • 创建并安装了配置文件 …

java apple-push-notifications

8
推荐指数
2
解决办法
4万
查看次数

标签 统计

apple-push-notifications ×1

java ×1