Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated legacy messaging methods are still available #2602

Closed
enixsoft opened this issue Jun 18, 2024 · 11 comments
Closed

Deprecated legacy messaging methods are still available #2602

enixsoft opened this issue Jun 18, 2024 · 11 comments

Comments

@enixsoft
Copy link

enixsoft commented Jun 18, 2024

Describe your environment

  • Operating System version: Ubuntu 22.04.4 LTS
  • Firebase SDK version: v12.1.1
  • Firebase Product: messaging
  • Node.js version: v20.12.2
  • NPM version: 10.5.0

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link
Author

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.

@enixsoft enixsoft reopened this Aug 14, 2024
@Johnnyrook777
Copy link

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
Copy link

devj3ns commented Aug 30, 2024

I think this is solved by #2683

@lahirumaramba
Copy link
Member

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

@UBT-FJ
Copy link

UBT-FJ commented Sep 15, 2024

I'm using quite old version, but my app is working!
"firebase-admin": "^11.2.0"

and getting this error:
Deprecated endpoint, see https://firebase.google.com/docs/cloud-messaging/migrate-v1\

while using this method:

// Send message const response = await admin.messaging(app).sendToDevice( user.mobileData.mobileToken, message, { priority: 'high', timeToLive: 60 * 60 * 24 } );

@CalvinJamesHeath
Copy link

You have to change from:

fcm.send(message, function (response) {
						let parsed = JSON.parse(response);
						if (parsed) {
							console.log('Something has gone wrong!', parsed);
							console.log(parsed.failure);
							if (parsed.failure === 1) {
								db.doc(`fcmtokens/${recipient}`).delete();
							}
						}
					});

To using the Admin SDK as so:

messaging.send(message)
						.then(() => {
							console.log('Push notification sent succesfully.');
						})
						.catch((err) => {
							console.log('ERROR PUSH', err);
						});

and from the notification object change the "to" key to "token"

{to: FCM_TOKEN //old way,
token: FCM_TOKEN }

@willysilalahi
Copy link

aw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants