Skip to content

Commit

Permalink
Fix usage of deprecated FCM call causing failures.
Browse files Browse the repository at this point in the history
The "sendMulticast()" function has been deprecated, and in fact
the way this function used to work is no longer supported server-side
by Firebase.

This was causing sendMulticast() to fail *silently*, since it doesn't
throw exceptions upon failure, but returns a list of successful and
unsuccessful responses. In our code, we don't really check the reason
for the failure, and just proceed to invalidate the associated device
token, assuming that it's no longer valid.

This updates our code to use the newly recommended sendEachForMulticast()
function, which is not exactly a drop-in replacement, since it doesn't
actually send a single multicast message, but rather multiple messages.
Nevertheless it uses an HTTP/2 connection, so performance should not be
impacted significantly.

This also adds a little more logging upon failure, and bumps the minimum
version of the Firebase dependency, and tidies up tests. It's not really
clear what exactly the test was testing (since it didn't catch this
failure). Expanding tests is something to visit in the future.

https://firebase.google.com/support/release-notes/admin/node#version_1170_-_18_april_2023
firebase/firebase-admin-node#2488

Bug: T379068
Change-Id: I6db51687bf1a16c15a274a21df1d472c2b349ea9
  • Loading branch information
dbrant committed Nov 7, 2024
1 parent bc6ab04 commit a8874bd
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 344 deletions.
Loading

0 comments on commit a8874bd

Please sign in to comment.