问题
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