【问题标题】:Implement google cloud messaging to send and receive push notification for android application in android studio在 android studio 中实现 google cloud 消息发送和接收 android 应用程序的推送通知
【发布时间】:2015-04-04 07:58:16
【问题描述】:

我想向我的应用程序发送推送通知。我的后端已准备就绪,我也能够从服务器接收 gcm 注册 ID,但我无法在我的设备上接收通知。任何人都可以帮助我。是否需要从 Play 商店下载应用程序才能发送通知,或者我们也可以在调试 apk 中测试通知?

我通过下面给出的链接实现了推送通知: http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/

【问题讨论】:

  • 你收到Unauthorized Error 401了吗?如果 Google API 密钥错误或 IP address of the server 机器未在 Google GCM 服务器上列入白名单。然后你会得到。此外,在该示例中,传递的数据必须是 JSON array
  • 我没有使用服务器密钥,而是在 api 控制台中使用浏览器密钥。
  • 你可以查看官方文档here获得一些想法

标签: android android-studio push-notification google-cloud-messaging


【解决方案1】:

GCM 通知与调试 APK 完美配合。

客户端代码或服务器代码有问题。

如果您从 Google 服务器获得成功响应,并且如果您能够在 GCM Intent 服务中看到收到的 GCM 消息的 logcat 日志,那么您的服务器端代码运行良好,并且客户端中可能存在错误代码。如果您从 Google 服务器收到失败消息或看不到日志,则问题出在您的服务器代码中。

注意:您需要使用服务器密钥。

您可以使用此GCM Test Tool 作为服务器来测试您的客户端是否正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    相关资源
    最近更新 更多