JavaPNS错误处理 - 文档中的矛盾? [英] JavaPNS error handling - contradiction in the documentation?

查看:316
本文介绍了JavaPNS错误处理 - 文档中的矛盾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaPNS文档,我看到:

In the JavaPNS docs, I see this:

要找出是否一推成功发送到苹果和苹果未返回任何错误响应包,只需调用pushedNotification.isSuccessful()方法。 如果这些情况发生的通知可能不会成功

To find out if a push was successfully sent to Apple and that Apple did not return any error-response packet, simply invoke the pushedNotification.isSuccessful() method. A notification might not be successful if any of these conditions occur:


      
  • 图书馆拒绝你,因为明显违反规范所提供的令牌(例如:令牌不是64字节长等)

  •   
  • 图书馆拒绝你,因为明显违反规范所提供的有效载荷(例如:负载过大等)

  •   
  • 发生了连接错误和库无法与苹果服务器进行通信

  •   
  • 您的证书或密钥库发生错误(例如:密码错误,无效的密钥库格式等)

  •   
  • 一个有效的错误响应数据包从苹果服务器接收

  •   
  • the library rejected the token you provided because of obvious specs violations (ex: token not 64-bytes long, etc.)
  • the library rejected the payload you provided because of obvious specs violations (ex: payload too large, etc.)
  • a connection error occurred and the library was not able to communicate with Apple servers
  • an error occurred with your certificate or keystore (ex: wrong password, invalid keystore format, etc.)
  • a valid error-response packet was received from Apple servers

和许多其他可能的错误...

但随后提供的code片段确实

But the code snippet provided then does

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());
        }
     }
 }

这似乎在暗示,isSuccess()== false意味着不可恢复的错误,并且该设备令牌是无效的。

Which seems to imply that isSuccess() == false means an unrecoverable error, and that the device token is not valid.

不过,可能的原因列表并说isSUccess()可能是假的,由于返回一个合法的差错报文。我不知道,但我想人们可能会被退回,如果苹果未能发送通知,由于运营商的问题,例如,这意味着令牌不一定无效。

However, the list of possible reasons did say that isSUccess() might be false due to a legitimate error packet being returned. I don't know, but I imagine one might be returned if Apple failed to send the notification due carrier issues, for example, which means the token is not necessarily invalid.

是读这个正确的方法,那么,isSuccess()==假时发送消息,而不是一个需要例外,如密钥库失败或无法在连接到服务器的不可恢复的错误所有?

Is the correct way to read this, then, that isSuccess() == false is an unrecoverable error when sending a message, but not one that requires an exception, like a keystore fail or an inability to connect to the servers at all?

在换句话说 - ID isSuccessful()==假的,应该我真的删除我的数据库设备令牌的建议?该段说是,但文档在我看来,并非如此......

In other words - id isSuccessful() == false, should I really delete the device token from my DB as suggested? The snippet says yes, but the documentation seems to me to suggest otherwise...

链接: HTTP://$c$c.google.com/ p / javapns /维基/ ManagingPushErrors

在此先感谢的人谁冒着这么久,漫无边际的问题。

Thanks in advance to anyone who has braved this long, rambling question.

- 浮潜

推荐答案

文档说,你是正确的。从技术上讲就意味着失败的推动,而不是它失败,因为一个例外。这可能是因为合法故障而失败的。 (我定义为我们成功地连接合法失败,有与消息没有明显的缺陷,但服务器拒绝接受。)关键线路如下:

The documentation says that you are correct. Technically it means the push failed, but not that it failed because of an exception. It could have failed because of a legitimate failure. (I define legitimate failure as we successfully connected, there were no obvious defects with the message, but the server declined to accept it.) The key line is the following:

IE 要了解一推成功发送到苹果和苹果未返回任何错误响应包,只需调用pushedNotification.isSuccessful()方法。

您整个问题似乎pretty迂回虽然。在一个简单的意义上说,你推失败。是否异常和失败之间的区别真的重要吗?无论哪种方式,它的不可恢复的,你需要检查日志,看看到底发生了什么。

Your whole question seems pretty roundabout though. In a simple sense, your push failed. Does the distinction between an exception and a failure really matter? Either way its unrecoverable and you need to check the logs to see exactly what happened.

这篇关于JavaPNS错误处理 - 文档中的矛盾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆