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

Discontinued FCM Messaging API #804

Closed
vigneshgurusamy opened this issue Jun 21, 2023 · 15 comments · Fixed by #805
Closed

Discontinued FCM Messaging API #804

vigneshgurusamy opened this issue Jun 21, 2023 · 15 comments · Fixed by #805
Assignees

Comments

@vigneshgurusamy
Copy link

Describe the bug

Messaging sendMulticast() method uses discontinued Google FCM API.

Ref: firebase/firebase-admin-node#2138

Suggest me if there is any alternate solution like using different method to send message to multiple devices.

Installed packages

{
    "require": {
        "kreait/firebase-php": "^7.2.1",
    }
}

PHP version and extensions

composer                2.5.5     Composer package
composer-plugin-api     2.3.0     The Composer Plugin API
composer-runtime-api    2.2.2     The Composer Runtime API
ext-calendar            8.2.7     The calendar PHP extension
ext-ctype               8.2.7     The ctype PHP extension
ext-curl                8.2.7     The curl PHP extension
ext-date                8.2.7     The date PHP extension
ext-dom                 20031129  The dom PHP extension
ext-exif                8.2.7     The exif PHP extension
ext-ffi                 8.2.7     The FFI PHP extension
ext-fileinfo            8.2.7     The fileinfo PHP extension
ext-filter              8.2.7     The filter PHP extension
ext-ftp                 8.2.7     The ftp PHP extension
ext-gd                  8.2.7     The gd PHP extension
ext-gettext             8.2.7     The gettext PHP extension
ext-gmp                 8.2.7     The gmp PHP extension
ext-hash                8.2.7     The hash PHP extension
ext-iconv               8.2.7     The iconv PHP extension
ext-igbinary            3.2.13    The igbinary PHP extension
ext-imagick             3.7.0     The imagick PHP extension
ext-intl                8.2.7     The intl PHP extension
ext-json                8.2.7     The json PHP extension
ext-libxml              8.2.7     The libxml PHP extension
ext-mbstring            8.2.7     The mbstring PHP extension
ext-openssl             8.2.7     The openssl PHP extension
ext-pcntl               8.2.7     The pcntl PHP extension
ext-pcre                8.2.7     The pcre PHP extension
ext-pdo                 8.2.7     The PDO PHP extension
ext-pdo_pgsql           8.2.7     The pdo_pgsql PHP extension
ext-pdo_sqlite          8.2.7     The pdo_sqlite PHP extension
ext-pgsql               8.2.7     The pgsql PHP extension
ext-phar                8.2.7     The Phar PHP extension
ext-posix               8.2.7     The posix PHP extension
ext-random              8.2.7     The random PHP extension
ext-readline            8.2.7     The readline PHP extension
ext-redis               5.3.7     The redis PHP extension
ext-reflection          8.2.7     The Reflection PHP extension
ext-session             8.2.7     The session PHP extension
ext-shmop               8.2.7     The shmop PHP extension
ext-simplexml           8.2.7     The SimpleXML PHP extension
ext-sockets             8.2.7     The sockets PHP extension
ext-sodium              8.2.7     The sodium PHP extension
ext-spl                 8.2.7     The SPL PHP extension
ext-sqlite3             8.2.7     The sqlite3 PHP extension
ext-sysvmsg             8.2.7     The sysvmsg PHP extension
ext-sysvsem             8.2.7     The sysvsem PHP extension
ext-sysvshm             8.2.7     The sysvshm PHP extension
ext-tokenizer           8.2.7     The tokenizer PHP extension
ext-xdebug              3.2.0     The xdebug PHP extension
ext-xml                 8.2.7     The xml PHP extension
ext-xmlreader           8.2.7     The xmlreader PHP extension
ext-xmlwriter           8.2.7     The xmlwriter PHP extension
ext-xsl                 8.2.7     The xsl PHP extension
ext-zend-opcache        8.2.7     The Zend OPcache PHP extension
ext-zip                 1.21.1    The zip PHP extension
ext-zlib                8.2.7     The zlib PHP extension
lib-curl                7.81.0    The curl library
lib-curl-libssh         0.9.6     curl libssh version
lib-curl-openssl        3.0.2     curl OpenSSL version (3.0.2)
lib-curl-zlib           1.2.11    curl zlib version
lib-date-timelib        2022.07   date timelib version
lib-date-zoneinfo       0         zoneinfo ("Olson") database for date
lib-fileinfo-libmagic   540       fileinfo libmagic version
lib-gd                  2.3.3     The gd library
lib-gmp                 6.2.1     The gmp library
lib-iconv               2.35      The iconv library
lib-icu                 70.1      The ICU unicode and globalization support library
lib-icu-cldr            40        ICU CLDR project version
lib-icu-unicode         14.0.0    ICU unicode version
lib-icu-zoneinfo        2023.3    zoneinfo ("Olson") database for icu
lib-imagick-imagemagick 6.9.11.60 The imagick-imagemagick library
lib-libsodium           1.0.18    The libsodium library
lib-libxml              2.9.14    libxml library version
lib-libxslt             1.1.34    The libxslt library
lib-libxslt-libxml      2.9.13    libxml version libxslt is compiled against
lib-mbstring-libmbfl    1.3.2     mbstring libmbfl version
lib-mbstring-oniguruma  6.9.7     mbstring oniguruma version
lib-openssl             3.0.2     OpenSSL 3.0.2 15 Mar 2022
lib-pcre                10.40     The pcre library
lib-pcre-unicode        14.0.0    PCRE Unicode version support
lib-pdo_pgsql-libpq     14.8      libpq for pdo_pgsql
lib-pdo_sqlite-sqlite   3.37.2    The pdo_sqlite-sqlite library
lib-sqlite3-sqlite      3.37.2    The sqlite3-sqlite library
lib-zip-libzip          1.7.3     The zip-libzip library
lib-zlib                1.2.11    The zlib library
php                     8.2.7     The PHP interpreter
php-64bit               8.2.7     The PHP interpreter, 64bit
php-ipv6                8.2.7     The PHP interpreter, with IPv6 support

Steps to reproduce the issue.

foreach (array_chunk($tokens->pluck('token')->all(), 100) as $chunk) {
    $report = $this->messaging->sendMulticast($message, $chunk);

    foreach ($report->failures()->getItems() as $failure) {
        $this->parseFailureResponse($user, $failure);
    }
}

Error message/Stack trace

-

Additional information

I have received a mail from Google to alert me about the usage of discontinued API in one of my project.

FCM

@Coennie
Copy link

Coennie commented Jun 21, 2023

same!

@jeromegamez
Copy link
Member

Related: firebase/firebase-admin-java#834

The official docs still use the batch endpoint, I'll have to investigate the Admin Node SDK, on mobile I didn't yet see what really changed. I'll get to it once I can find some time.

For the time being, sending messages "the old way" still seems to work, so I think no immediate action is required.

While I'm at it: if your business relies on my SDK, please consider becoming a sponsor, I invest a considerable of time and work into it 🙏🏻

@FilibertoNencioni
Copy link

I've received the same email, Google will discontinue those methods on June 20, 2024.
immagine

@jeromegamez
Copy link
Member

Okay, if I'm not mistaken, in the Admin Node SDK, they now use n asynchronous requests to /v1/projects/${projectId}/messages:send instead of multi-part requests with n parts to /batch.

In the PHP SDK, sending a single message already uses the HTTP V1 API, so there's nothing to add.

But: all requests in this SDK are currently blocking, this means I cannot just make sendMulticast() call send() n times, because this would take forever.

Implementing this in an asynchronous way will require a considerable amount of thinking and work, and I can't give you an ETA other than "before June 20, 2024". 😅

@jeromegamez
Copy link
Member

Please don't open a PR for this, reviewing the code and requiring changes would take longer than implementing it myself in a way I feel comfortable maintaining down the road.

You can support the development of this change and the maintenance of this library in General by becoming a GitHub Sponsor.

@jeromegamez
Copy link
Member

Alright, I underestimated myself 😂 - I have this working locally and will try to make a (at first dirty) PR for you to test shortly

@xak2000
Copy link

xak2000 commented Jun 21, 2023

Ha-ha, it's so funny.. in a good way. 😂👍

  • Oh, that is so hard, it would probably take a year.
    (1 hour later)
  • OK, I done!

@jeromegamez
Copy link
Member

What should I say 😅. I do have a lot going on at the moment und just little time, but I had a window of opportunity and went for it 😅

Please test #805 and let me know (preferably in the PR comments) if this works for you - I myself have only two device tokens to test with 😅.

@jeromegamez
Copy link
Member

I started with new methods to replicate what the Node Admin SDK is doing, but that would have introduced a breaking change (adding new methods to the Messaging interface).

The new implementation of the existing methods are not the prettiest but should™ work and will be released in the next feature release 🤞🏻

@ankurk91
Copy link
Contributor

The docs must be updated too
https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html#send-messages-to-multiple-devices-multicast

It still says

You can send one message to up to 500 devices:

@jeromegamez
Copy link
Member

Oh, if it must then I certainly will not oppose it 🫡 (cb59ba0)

@kevinvanmierlo
Copy link

Is there a way to use these changes while our php version is still stuck on 7.4? Unfortunately I cannot update the php version for a few projects. But I'm not sure how to handle the change for the multicast without updating the php version (7.x releases requires php 8.1 and higher right?). The only other way I thought of was to fork the project and make the same changes in an earlier release. But before I take that route I was hoping there was an easier way.

@jeromegamez
Copy link
Member

It might be possible backport it to 6.x, but looking into if it's actually feasible and then doing it, is something that I'm not able/willing to do for free, I hope you understand.

I can offer you to do it for at least two consecutive months of my $500 sponsorship tier or an invoice for the same amount to be paid in advance (you asked for an easier way 😄).

Given that you've been using the SDK in several projects which probably generated more revenue than that, I consider this a more than fair proposal.

You could, of course, fork the project and do it yourself, but depending on how much you value your (team's) work, that might be more expensive.

@kevinvanmierlo
Copy link

@jeromegamez Thanks for the response! Of course I understand, I'm not expecting you to backport it for free. But great that you are willing to do so if we sponsor you! Haha it is indeed an easier way I was not expecting 😉 .

I will discuss this with my team to ask them what they would like. Besides that, since we are indeed using it in several projects. I put sponsoring this project on our list to discuss, to sponsor you anyway.

@jeromegamez
Copy link
Member

jeromegamez commented May 3, 2024

Thank you so much, I really appreciate it! 🙏🏻

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

Successfully merging a pull request may close this issue.

7 participants