Skip to content

[Notifier] [Firebase] Add Firebase v1 API support #60205

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

Open
wants to merge 7 commits into
base: 7.3
Choose a base branch
from

Conversation

vojtechsmejkal
Copy link

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? yes
Issues Fix #51147
License MIT

This PR adds support for the new v1 API.

The main changes were:

  • Changed authorization process to use short lived JWT
  • Changed DSN shape to provide all information required by new API
  • New API endpoint was used
  • FirebaseOptions were extended to hold params supported by new API

This PR does not break backwards compatibility meaning that new Firebase bridge should behave the same way inside the Symfony app as the old one does right now.

Support for the old API was completely removed as the API has been shut down in 2024 already and attempting to use it throws exceptions.

Deprecations

  • $token param in FirebaseTransport::__construct() was deprecated - the param no longer exists for the new API
  • AndroidNotification, IOSNotification and WebNotification classes were deprecated - new Firebase API allows for all platform specific options to be specified for the message and having options separated by platform limits usability
  • If you attempt to use the FirebaseTransport with the old DSN format a deprecation notice is triggered to inform the user to upgrade (this has been done mainly to not break apps which have the FirebaseTransport configured with the old credentials format)

@carsonbot carsonbot added this to the 7.3 milestone Apr 12, 2025
@carsonbot carsonbot changed the title [Notifier][Firebase] Add Firebase v1 API support [Notifier] [Firebase] Add Firebase v1 API support Apr 12, 2025
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot


return $sentMessage;
}

private function getJwt(): string
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating JWT is quite a heavy operation and for example a messages worker dedicated to sending push notifications would perform this operation many times.

Can I add caching for the generated JWT? If so, should I add symfony/cache dependency?

@vojtechsmejkal vojtechsmejkal force-pushed the notifier-firebase-v1-api-support branch 2 times, most recently from 200ece1 to a83a711 Compare April 12, 2025 15:54
@vojtechsmejkal vojtechsmejkal force-pushed the notifier-firebase-v1-api-support branch from a83a711 to 1ea778b Compare April 12, 2025 16:20
@vojtechsmejkal
Copy link
Author

Some tests on Windows are failing. It seems like ext-openssl is not installed on that environment. If my assumption is correct, what is the preferred way to resolve this?

Rest of the failing tests seem to come from Doctrine bridge which should be unrelated to changes made in this PR.

@vojtechsmejkal vojtechsmejkal force-pushed the notifier-firebase-v1-api-support branch 2 times, most recently from f213052 to 4d52e8a Compare April 21, 2025 08:40
Vojtech Smejkal added 7 commits May 10, 2025 14:12
New Firebase API uses JWT authorization and OpenSSL is needed for signing it.
…nion field from new API

New API changed the 'to' field into a union field with 3 different types. This adds backwards-compatible way to support targeting this union field in FirebaseOptions.
…the new v1 API

Backwards compatibility was maintained with the old DSN format. A deprecation is triggered when someone tries to create the transport with the old DSN format. Transport created using the old DSN will not be able to send messages and will throw exception for every sent message (this should be consistent with its previous behavior).
The private key used in tests was generated only for the purposes of these tests and is not connected to anything real.
… shape

Shape of the endpoint input has changed with the new API. Separating options for messages based on the target platform no longer makes sense as all options for all platforms can now be set for the same message.

AndroidNotification, IOSNotification and WebNotification were marked as deprecated and will be removed.

FirebaseOptions is no longer abstract and should be used directly.
Reflects changes made by transferring to new v1 API.
@vojtechsmejkal vojtechsmejkal force-pushed the notifier-firebase-v1-api-support branch from 4d52e8a to 0259dce Compare May 10, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firebase notifier does not work anymore since messaging protocol updated by google
2 participants