Skip to content

[Notifier] [Firebase] Add data field to options #40102

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

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

Raresmldvn
Copy link
Contributor

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets #40078
License MIT
Doc PR symfony/symfony-docs#...

The Firebase Notifier must comply to the specifications at https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref.html#notification-payload-support .
The options are missing the data field which is a common field for all types of notifications: web, ios and android.

@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 5.x 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

public function __construct(string $to, array $options)
protected $data;

public function __construct(string $to, array $options, array $data)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would prefer to use a key data inside options array, WDYT?

Copy link
Contributor Author

@Raresmldvn Raresmldvn Feb 5, 2021

Choose a reason for hiding this comment

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

Yes, I get what you're saying. The con for this is the toArray method that returns everything that is in options array for key notification and I would have to do some logic either in FirebaseTransport or here in toArray to retrieve what's there under the data key (and remove it from the notification key), if that makes sense
But it is doable indeed. 😄 Do you think it's worth it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it makes sense, but I don't get it 😄
When you add it to the options array and return it in toArray, we can use it there and if the (I hope I understood this right) transport is instantiated without FirebaseOptions we add the 'data' key to the payload as an empty array.

The main point is: Whenever I send a payload it needs to include a data key, right?

Copy link
Member

Choose a reason for hiding this comment

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

the options in the constructor does not actually represent the full options. It represents only the notication key in the firebase options (see toArray. To me, that's a naming issue in the FirebaseOptions class.

Copy link
Contributor Author

@Raresmldvn Raresmldvn Feb 8, 2021

Choose a reason for hiding this comment

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

I get what you are saying @OskarStark , but from my point of view, that options field is indeed a naming issue there and I suggest, for the sake of clarity in mapping the firebase api, to change it to something like notificationOptions/notification and add a separate data property.

Copy link
Contributor Author

@Raresmldvn Raresmldvn Feb 11, 2021

Choose a reason for hiding this comment

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

@stof do you think I should rename that field? I would really need this PR to be merged soon because I am a bit blocked on my implementation for push notifications on the project I'm currently working on.
Thanks 👍

(and thank you for the approval @OskarStark :D )

@chalasr chalasr added this to the 5.x milestone Feb 5, 2021
@fabpot fabpot force-pushed the enhancement/firebase-notifier-data branch from 19f4620 to fa8064b Compare February 11, 2021 07:48
@fabpot
Copy link
Member

fabpot commented Feb 11, 2021

Thank you @Raresmldvn.

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.

6 participants