1

我用谷歌搜索了 javapns,没有任何迹象表明它支持广播扩散。让它支持广播有诀窍吗?

我现在正在使用此代码,并在调用中添加我所有可用的令牌:

    try {

        PushNotificationPayload payload = PushNotificationPayload.complex();

        payload.addAlert("Hello World");
        payload.addBadge(1);
        payload.addSound("default");
        payload.addCustomDictionary("id", "1");

        System.out.println(payload.toString());
        List<PushedNotification> NOTIFICATIONS = Push
                .payload(payload, "D:\\keystore1.p12", "123456", true,
                        "-------------");           
         for (PushedNotification NOTIFICATION : NOTIFICATIONS) {
            if (NOTIFICATION.isSuccessful()) {
                /* APPLE ACCEPTED THE NOTIFICATION AND SHOULD DELIVER IT */
                System.out
                        .println("PUSH NOTIFICATION SENT SUCCESSFULLY TO: "
                                + NOTIFICATION.getDevice().getToken());
                /* STILL NEED TO QUERY THE FEEDBACK SERVICE REGULARLY */
            } else {
                String INVALIDTOKEN = NOTIFICATION.getDevice().getToken();
                /* ADD CODE HERE TO REMOVE INVALIDTOKEN FROM YOUR DATABASE */

                /* FIND OUT MORE ABOUT WHAT THE PROBLEM WAS */
                Exception THEPROBLEM = NOTIFICATION.getException();
                THEPROBLEM.printStackTrace();

                /*
                 * IF THE PROBLEM WAS AN ERROR-RESPONSE PACKET RETURNED BY
                 * APPLE, GET IT
                 */
                ResponsePacket THEERRORRESPONSE = NOTIFICATION
                        .getResponse();
                if (THEERRORRESPONSE != null) {
                    System.out.println(THEERRORRESPONSE.getMessage());
                }
            }
        }

    } catch (Exception e) {
          System.out.println("Error: " + e);

    }
4

1 回答 1

1

真正的广播通知不存在。IOS 推送通知服务只有一种实现,它需要客户端的令牌列表。

因此,您必须获取客户的令牌,然后使用您的脚本。

于 2015-06-26T10:51:00.157 回答