简体   繁体   English

从GCM帮助程序库迁移到GCM Api

[英]Migrating from GCM helper library to GCM Api

I am used to sending GCM messages from my App Server (AppEngine) to my Clients using the GCM java library GCM-Server.jar but I found is has been deprecated . 我习惯于使用GCM Java库GCM-Server.jar从我的App Server(AppEngine)向我的客户端发送GCM消息,但发现已被弃用

Till now, I am used to send messages using: 到目前为止,我习惯于使用以下方式发送消息:

    Sender sender = new Sender(Constants.API_KEY);
    Message message = new Message.Builder()
        .addData(Constants.TO, to).addData(Constants.FROM, from).addData(Constants.MSG, msg)
        .build();

    MulticastResult result = sender.send(message, regIds, 5);
    //(regIds is a list<string>

Also, If I browse the web, or look up some tutorials on how to use GCM from your Java Server, I can only find ones that use the deprecated method. 另外,如果我浏览Web或在Java Server上查找有关如何使用GCM的一些教程,则只能找到使用不推荐使用的方法的教程。

Even the official sample uses this method: https://code.google.com/p/gcm/source/browse/samples/gcm-demo-server/src/com/google/android/gcm/demo/server/SendAllMessagesServlet.java 甚至官方样本也使用这种方法: https : //code.google.com/p/gcm/source/browse/samples/gcm-demo-server/src/com/google/android/gcm/demo/server/SendAllMessagesServlet。爪哇

Is there any information on how to upgrade/migrate to the new API, some example would be great. 是否有有关如何升级/迁移到新API的信息,一些示例将是很棒的。

Only the client library (gcm.jar) was deprecated. 仅弃用了客户端库(gcm.jar)。 The server library (gcm-server.jar) is not deprecated and you can continue using it (unless you decide to connect to the newer GCM Cloud Connection Server, which is not necessary), regardless to whether you use or don't use the deprecated library in the client side. 服务器库(gcm-server.jar)尚未被弃用,您可以继续使用它(除非您决定连接到较新的GCM Cloud Connection Server,这是不必要的),无论您使用还是不使用客户端中已弃用的库。

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

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