GCM java服务器示例 [英] GCM java server example

查看:232
本文介绍了GCM java服务器示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有链接到GCM Java第三方服务器的例子?我无法理解如何实现它。在 http://developer.android.com/google/gcm/server.html,我找不到一个完整的例子。

Does anyone have a link to GCM java 3rd Party Server example? I can't understand how to implement it. In http://developer.android.com/google/gcm/server.html, I could not find a complete example.

推荐答案

最简单的方法是使用 gcm- server.jar (您可以从此处获取)。

The easiest way is to use gcm-server.jar (which you can get from here).

然后,您需要发送GCM消息的代码如下所示:

Then the code you'll need to send a GCM message will look like this :

Sender sender = new Sender(apiKey);
Message message = new Message.Builder()
    .addData("message", "this is the message")
    .addData("other-parameter", "some value")
    .build();
Result result = sender.send(message, registrationId, numOfRetries);

这篇关于GCM java服务器示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆