Ways to guess if C2DM is connected

后端 未结 8 1445
花落未央
花落未央 2021-02-02 15:13

I\'m trying to place a best guess estimate as to whether C2DM messages can be received.

I\'ve created an application that relies on pushing information to a phone while

8条回答
  •  -上瘾入骨i
    2021-02-02 15:30

    I've worked a little with C2Dm, I've created my own push 3rd party server . I've implemented a little logic based oh C2DM http response code to know if a push message was sent or not . Here is some of the code I used :

    int responseCode = conn.getResponseCode();
    
        if (responseCode == HttpServletResponse.SC_UNAUTHORIZED || responseCode == HttpServletResponse.SC_FORBIDDEN) {
    
            LOGGER.warn("Unauthorized - need token");
    
            return false;
        }
    

    here I'm almost sure that the push message was sent from the c2dm servers because I've got an id ont the response:

    if (responseParts[0].equals("id")) {
            LOGGER.info("Successfully sent data message to device: " + responseLine);
    
            return true;
        }
    

    I've used other methods to get other result codes from Google if you want I can post them.I hope that I've helped you a bit .

提交回复
热议问题