2

javapns 2.2 を使用してプッシュ通知を送信し、そこから正常な応答を得ていますが、iOS テスト電話に通知が表示されません。wiki からこのコードを使用する単体テストを作成しました。

@Test
public void shouldSendATestMessageNotifyingDeviceThatNewMessageIsReady()
        throws RepositoryException {
    NotificationService nService = new NotificationService();
    nService.sendNotification("incoming message",
            "4854862ec7b58a939538f2e1262a48a7e8a3331c5f0e11feb11e1a79ff764649");
}

public void sendNotification(String message, String deviceId) {
    try {
        List<PushedNotification> notifications = Push.alert(message, certLocation, certPassword, false,
                deviceId);
        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 (CommunicationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (KeystoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

キーチェーンで作成した本番プッシュ SSL 証明書 (p12) を使用しています。iOS デバイスにアドホック ビルドがあり、テストに使用しているデバイスの iOS アプリのコードからこのテストに渡すデバイス ID をNSLog取得したので、有効です。

prod cert を dev cert に交換したところ、無効なトークン エラーが発生しました。

プッシュされたメッセージが正常に送信されたとjavapnsが教えてくれるので、他に何を見ればよいかわかりません。アイデア?

4

0 に答える 0