1
votes

I have been sending push notifications from my Java Server and It has been working fine.But for some reason my Apps are no longer receiving the push notifications. Nothing has changed on the Server. Is there something that has changed on codenameone that I should be catering for?

below is the same code that I use which is based on the codnameone example. I receive the 200 response when I send the push notification but I do not receive the actual push.

connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
String cert = ITUNES_DEVELOPMENT_PUSH_CERT;
String pass = ITUNES_DEVELOPMENT_PUSH_CERT_PASSWORD;
if(ITUNES_PRODUCTION_PUSH) {
    cert = ITUNES_PRODUCTION_PUSH_CERT;
    pass = ITUNES_PRODUCTION_PUSH_CERT_PASSWORD;
}
String query = "token="  + PUSH_TOKEN +
    "&device=" + URLEncoder.encode(deviceId1, "UTF-8") +
    "&device=" + URLEncoder.encode(deviceId2, "UTF-8") +
    "&device=" + URLEncoder.encode(deviceId3, "UTF-8") +
    "&type=1" +
    "&auth=" + URLEncoder.encode(GCM_SERVER_API_KEY, "UTF-8") +
    "&certPassword=" + URLEncoder.encode(pass, "UTF-8") +
    "&cert=" + URLEncoder.encode(cert, "UTF-8") +
    "&body=" + URLEncoder.encode(MESSAGE_BODY, "UTF-8");
try (OutputStream output = connection.getOutputStream()) {
    output.write(query.getBytes("UTF-8"));
}
int c = connection.getResponseCode();```
1

1 Answers

0
votes

A 200 response is always returned but a JSON string is also readable via the connection. Did you read it?

This is an omission in the docs where the result from connection isn't read/parsed. See the "Server JSON Responses" section here: https://www.codenameone.com/manual/push.html

If both iOS and Android are unreachable I'm guessing your subscription billing might have elapsed.