本文介绍了Android的GCM不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用由古尔提供的例子,我建立了一个客户端应用程序接收通知和服务器端,这两个应用程序(code)为那些由谷歌提供。

I use the example provided by goole and I built an client side application to get notifications and a server side, both applications (code) is those provided by google.

我运行在客户端的应用程序,我得到的registration_id。一些巨大的字符串,这种格式是如下:

I run the application on the client side and I get the registration_id. some huge string, in this format which is below:

<$c$c>APA91bEgguwt98xLbivrXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXLxDalNoEktCSVbOkT0-uFH2FaRnfpkRME2tzuvr0BycMNEhX_Ix1PV_XXXXXXXXXXXXXXXXXXXXXN5hcseY_wA.

这证明我的客户端应用程序的工作原理。现在,服务器(Java,谷歌为例):

This proves me that the client application works. Now the server (java, google example):

public static void main(String[] args) {

        Sender sender = new Sender("AIzaSXXXXXXXXXX_XXXXXXXXXXXXXXXrQOnoGZw");
        Message message = new Message.Builder()
        .collapseKey("1")
        .timeToLive(3)
        .delayWhileIdle(true)
        .addData("message",
          "this text will be seen in notification bar!!")
        .build();

        try {
            Result result = sender.send(message, "APA91bEgguwt98xLbivrXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXLxDalNoEktCSVbOkT0-uFH2FaRnfpkRME2tzuvr0BycMNEhX_Ix1PV_XXXXXXXXXXXXXXXXXXXXXN5hcseY_wA", 3);
            System.out.println(result.toString());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

这是服务器。当我运行的服务器我得到的结果是这样的: [邮件ID = 0:1341907115903155%921c249a00000031] 但在客户端上没有消息,我不明白为什么。什么是我从服务器上得到的回应是什么意思?它是成功的回应?

This is the server. When I run the server I got as result something like this:[ messageId=0:1341907115903155%921c249a00000031 ]but no message on the client and I don't understand why. What is the meaning of the response I got from server? Is it the success response?

我需要帮助来理解什么是错的?

I need help to understand what is wrong?

推荐答案

根据该的:

在第三方服务器上发布消息到GCM和接收消息ID后面,但这并不意味着该邮件已经发送到设备。相反,它意味着它被接受交付。会发生什么事被接受后,该消息取决于许多因素。

在最好的情况下,如果该装置被连接到GCM,屏幕上,并且没有节流限制(见节流),该消息将被立即递送

In the best-case scenario, if the device is connected to GCM, the screen is on, and there are no throttling restrictions (see Throttling), the message will be delivered right away.

这篇关于Android的GCM不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 11:22
查看更多