简体   繁体   English

GCM使用Java发送消息

[英]GCM sending message using java

Using nodejs and node-gcm I'm sending message to my android client using this code 使用nodejs和node-gcm我正在使用此代码向我的android客户端发送消息

var sender = new gcm.Sender('API KEY');
sender.send(message, regId, function(err, result) {
         if (err) console.log("error");
         else console.log("Message sent! :)");

There is something similar on Java? Java上有类似的东西吗? I found this 我找到了这个

Sender sender = new Sender(GCM_API_KEY);
try {
        Result res = sender.send(message, "token", 3);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But with the Java Sender I can't set the client id. 但是,使用Java Sender,我无法设置客户端ID。 How can I do? 我能怎么做?

There is no client id needed for sending a GCM message with the Sender class. 使用Sender类发送GCM消息不需要客户端ID。 All you need are the API key and the Registration ID (to be placed where you wrote "token" ). 您只需要API密钥和注册ID(放置在您编写"token" )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM