0

ResponsePacket theErrorResponse = pushNotification.getResponse();私は javapns2.2 を使用しており、アップルの拡張通知形式からのエラー応答パケットをキャッチしようとしています。プッシュ通知を送信すると(無効なトークンなど)、コード

Exception theProblem = pushedNotification.getException();
theProblem.printStackTrace();

コンソールにエラーを出力しますが、

ResponsePacket theErrorResponse = pushedNotification.getResponse();
if (theErrorResponse != null && theErrorResponse.isErrorResponsePacket()) {
      System.out.println(theErrorResponse.getMessage());
      System.out.println(theErrorResponse.getStatus());
}

常にnull を返します。getResponse() でステータス コードを取得するにはどうすればよいですか?

ここに私のコードの一部があります:

List<PushedNotification> notifications = Push.payload(payload, keystore, password, production, devices);

        for (PushedNotification pushedNotification : notifications) {
            if(pushedNotification.isSuccessful())
            {
                System.out.println(pushedNotification.getDevice().getToken());                  
            }
            else
            {
                System.out.println(pushedNotification.getDevice().getToken());

                Exception theProblem = pushedNotification.getException();
                theProblem.printStackTrace();

                ResponsePacket theErrorResponse = pushedNotification.getResponse();
                if (theErrorResponse != null && theErrorResponse.isErrorResponsePacket()) {
                        System.out.println(theErrorResponse.getMessage());
                        System.out.println(theErrorResponse.getStatus());
                }

            }
        }

ご協力ありがとうございました

4

1 に答える 1

1

私はそれを考え出した。

getResponse() は null を返します。これは、例外メカニズムが APNs への呼び出しの効率化を妨げているためです。真のエラーは、例外メカニズム内にパックされます。

すべてがこのリンクで非常に説明されています: http://code.google.com/p/javapns/issues/detail?id=79&can=1

于 2012-05-18T14:07:27.533 に答える