firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.62k stars 367 forks source link

Deprecated legacy messaging methods are still available #2602

Closed enixsoft closed 1 week ago

enixsoft commented 2 months ago

Describe your environment

Describe the problem

According to FAQ for FCM features deprecated in June 2023, the API endpoint https://fcm.googleapis.com/fcm/send is shutting down and:

Requests to the endpoint will start failing after 6/21/2024.

It has been replaced by HTTP v1 endpoint: https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send

However, in this latest v12.1.1 version of firebase-admin-node, there are 4 methods still using this legacy endpoint:

Only methods sendToDevice and sendToDeviceGroup are marked as deprecated, but methods sendToTopic and sendToCondition are not - despite all of them using the same endpoint. But won't all four of them stop working soon? So shouldn't they have been already removed in the latest version? It is a breaking change.

Johnnyrook777 commented 1 month ago

These are now throwing Error sending to topic FirebaseMessagingError: An unknown server error was returned. Raw server response: "{"error":"Deprecated endpoint, see https://firebase.google.com/docs/cloud-messaging/migrate-v1"}"

DevDianDankie commented 1 month ago

Yes @Johnnyrook777 for me as well. sentToTopic is an important one for our business and now not working anymore. I am using v 12.3.1.

DevDianDankie commented 1 month ago

If I look here the example seems to indicate that the new send method will also handle topics?

https://firebase.google.com/docs/cloud-messaging/migrate-v1#update-the-payload-of-send-requests

I am going to update and test and refer back here if it was successful or not

DevDianDankie commented 1 month ago

Yes using .send() instead of sendToTopic() works. sendToCondition will probably also work as it can take the message type is:

export type Message = TokenMessage | TopicMessage | ConditionMessage;

enixsoft commented 1 month ago

Yes, .send() works fine as a replacement, but the issue is that those deprecated methods that no longer work are still present in the latest version (now 12.3.1) and some aren't even marked as deprecated. It seems developers here simply doesn't care even though notifications are essential to many apps.

Johnnyrook777 commented 4 weeks ago

Thanks @DevDianDankie, I also had success using a TopicMessage and .send.

Seems like an oversight to not have the old functions migrated or depicated, and we certainly got caught off guard :(

devj3ns commented 2 weeks ago

I think this is solved by https://github.com/firebase/firebase-admin-node/pull/2683

lahirumaramba commented 1 week ago

Hey folks, sendToTopic and sendToCondition should have been marked as deprecated along with the other deprecated FCM APIs. We missed it. I apologies for the confusion this caused. The APIs are now deprecated in v12.4.0+

Please use the send() API instead.

Send messages to topics