kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
994 stars 163 forks source link

Config to disable Cloud Messaging #112

Closed fabiomlferreira closed 1 year ago

fabiomlferreira commented 2 years ago

I'm having a problem, I have a project that is already in production, and I'm working in the development project but I don't have a easy way to disable the Cloud Messaging to prevent to spam real clients.

The only solution that I found is to create a second firebase account and use that credentials but I think we should have a config for .env to disable Firebase, for example FIREBASE_ENABLED=false.

devglrd commented 2 years ago

Feel free to make a PR

jeromegamez commented 2 years ago

I think a PR won't help 😅. Having a separate Firebase project is currently the recommended (only) way to do it with the PHP SDK, and was the only way to do it before Google released the emulator suite. Support for the emulators will come eventually, but I can't tell you when.

Perhaps I will be able to add a NOOP implementation before that, but I'm currently on vacation and don't know when I'll have the resources for it, so I don't have an ETA for that either.

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let me know if that works for you by leaving a 👍. Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

ankurk91 commented 1 year ago

One can use the Laravel events

 \Illuminate\Notifications\Events\NotificationSending::class => [
            \App\Listeners\Notification\PreventFCMWhenDisabled::class,
        ],
jeromegamez commented 1 year ago

I'm closing this issue because using a separate project remains the only way to do it with the SDK. It now has support for the Emulator Suite, but there's no emulator for FCM (yet).

I haven't tested if/how @ankurk91's suggestion works, but perhaps the can elaborate so that you can implement this as well.