kreait / firebase-bundle

A Symfony Bundle for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
135 stars 25 forks source link

Overriding project id per configuration entry #62

Closed rogierknoester closed 1 week ago

rogierknoester commented 1 week ago

Describe the feature you would like to see

Hi,

we're starting to use your bundle (and great lib) for push notifications. In our situation our backend service lives in project A and the apps live in project B. We run within GCP so our workloads have a service account for project A available. This service account has been given the roles for FCM in project B. It can send notifications when testing locally (with SA key file for project A but changing the project to B manually in the file). However, when we deploy the service account that is automatically provided will resolve to project A, not B. Meaning it cannot send messages. Ideally, it would be possible to simply override with an extra config entry field:

kreait_firebase:
    projects:
        some-project-name:
            project_id: project-b

In the base library this seems possible by calling ::withProjectId(...), so right now I am leaning to use the library directly and write a new factory. But of course, being able to do this with the bundle is more appropriate.

Is there something I am missing or is it indeed a usecase that is not supported yet? If it is not supported would a PR be welcome?

jeromegamez commented 1 week ago

No, I think you are describing it correctly, this currently isn't possible (and to be honest, I didn't know it was possible to send messages from Project A to devices in Project B, that's nice!)

A PR would be great, but perhaps I can find some time on the weekend - let's see who is faster 😅

rogierknoester commented 1 week ago

let's see who is faster 😅

I took the liberty to write it already, it's not much but I think it does the job :)