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用于我用于测试的设备,因此它是有效的。

我用开发证书交换了我的产品证书,并得到了无效的令牌错误,因为我希望确保它正在找到文件。

不知道还有什么可以看的,因为 javapns 告诉我推送的消息已成功发送。想法?

4

0 回答 0