Migrate from gcm to fcm in the server

∥☆過路亽.° 提交于 2021-02-08 07:48:57

问题


in this article (https://developers.google.com/cloud-messaging/android/android-migrate-fcm#update-server-endpoints) it says that for migrating from gcm to fcm all you need to do in the server is change the endpoint.

but how do i do this?

currently i'm using gcm client library for Java. what exactly do i need to do? i couldn't find anywhere instruction how to update the endpoint.

do i need to stop using the gcm client library and move to the fcm client library?


回答1:


There is no FCM client library. It is actually supported by the one you already use.

You can specify to which endpoint a message should be sent in the constructor for Sender.

Sender sender = new Sender(apiKey, Constants.FCM_SEND_ENDPOINT);
Message message = new Message.Builder()
    .addData("message", "a message")
    .build();
Result result = sender.send(message, registrationId, numberOfRetries)

Note that if you do not specify an endpoint, it defaults to FCM.

If you are using a recent version of the lib, you probably don't have to change anything.



来源:https://stackoverflow.com/questions/51477224/migrate-from-gcm-to-fcm-in-the-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!