【问题标题】:Codenameone Android and IOS app not receiving push notifications from Java ServerCodenameone Android 和 IOS 应用程序未收到来自 Java 服务器的推送通知
【发布时间】:2019-09-25 21:44:35
【问题描述】:

我一直在从我的 Java 服务器发送推送通知,它一直工作正常。但由于某种原因,我的应用程序不再接收推送通知。服务器上没有任何变化。代号上是否有一些我应该注意的地方发生了变化?

下面是我使用的相同代码,它基于 codnameone 示例。我在发送推送通知时收到 200 响应,但没有收到实际推送。

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

【问题讨论】:

    标签: codenameone


    【解决方案1】:

    始终返回 200 响应,但也可以通过连接读取 JSON 字符串。你读了吗?

    这是文档中未读取/解析连接结果的遗漏。请参阅此处的“服务器 JSON 响应”部分:https://www.codenameone.com/manual/push.html

    如果 iOS 和 Android 都无法访问,我猜您的订阅账单可能已经过期。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-22
      • 1970-01-01
      • 2019-04-19
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      • 2016-07-22
      相关资源
      最近更新 更多