Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何让GCM推送通知在android上工作?_Java_Android_Notifications_Push Notification_Google Cloud Messaging - Fatal编程技术网

Java 如何让GCM推送通知在android上工作?

Java 如何让GCM推送通知在android上工作?,java,android,notifications,push-notification,google-cloud-messaging,Java,Android,Notifications,Push Notification,Google Cloud Messaging,我正在使用作为后端谷歌应用程序引擎。 我从谷歌API激活了我的GCM项目,我有我的API密钥。 我设法注册了每个用户,在我的数据库中,每个用户都有一个regid,它从android应用程序发送到我的服务器。此ID由gcm生成 现在怎么办?我尝试向我的所有regid用户发送通知,但似乎没有任何通知出现 我应该在android应用程序中自己创建通知吗?如果是,如何以及在哪里 另外,这是我后端的java代码:这是正确的还是我应该使用gcm特定的东西 ` List regIds = new ArrayL

我正在使用作为后端谷歌应用程序引擎。 我从谷歌API激活了我的GCM项目,我有我的API密钥。 我设法注册了每个用户,在我的数据库中,每个用户都有一个regid,它从android应用程序发送到我的服务器。此ID由gcm生成

现在怎么办?我尝试向我的所有regid用户发送通知,但似乎没有任何通知出现

我应该在android应用程序中自己创建通知吗?如果是,如何以及在哪里

另外,这是我后端的java代码:这是正确的还是我应该使用gcm特定的东西

` List regIds = new ArrayList<String>();
        regIds.add("APA91bG_pKoxxxxxxxx......");
        regIds.add("APA91bF_uxoo0-xxxxxx....");`

`// If you want the SDK to automatically retry a certain number of times, use the
// standard send method.
        Sender sender = new Sender("AIzaSyAgxxxxxxxxxxxxxxxxxxxxxxx");
        Message message = new Message.Builder()
                .addData("message", "Hello")
                .addData("location", "000 111 33")
                .build();
        try {
            MulticastResult result = sender.send(message, regIds, 5);
        }
        catch (Exception e) {
            temp.setData(e.toString());
        }
        return temp ;
`
换句话说,如何进行第5步和第6步


谢谢你的帮助

要在Android应用程序上处理推送通知,您应该实现自己的BroadcastReceiver来接收和意图服务来处理传入消息。并更新舱单。我建议你仔细阅读