https://github.com/dimajolkin/symfony-firebase-notifier
https://github.com/dimajolkin/symfony-firebase-notifier
firebase symfony
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dimajolkin/symfony-firebase-notifier
- Owner: dimajolkin
- Created: 2024-06-22T12:43:57.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-24T13:48:31.000Z (11 months ago)
- Last Synced: 2025-08-24T18:52:28.691Z (11 months ago)
- Topics: firebase, symfony
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Firebase Notifier
### Install
```bash
composer required dimajolkin/symfony-firebase-notifier
```
### Docs
Provides Firebase integration for Symfony Notifier.
Adapted for using http
Base copy from : https://github.com/symfony/firebase-notifier
```php
include __DIR__ .'/../vendor/autoload.php';
use Dimajolkin\SymfonyFirebaseNotifier\Credential;
use Dimajolkin\SymfonyFirebaseNotifier\FirebaseTransport;
use Dimajolkin\SymfonyFirebaseNotifier\MessageType\TargetMessageOptions;
use Dimajolkin\SymfonyFirebaseNotifier\Notification\AndroidNotification;
use Dimajolkin\SymfonyFirebaseNotifier\Notification\CommonNotification;
use Symfony\Component\Notifier\Chatter;
use Symfony\Component\Notifier\Exception\TransportException;
use Symfony\Component\Notifier\Message\ChatMessage;
$file = file_get_contents('......json');
$token = Credential::fromServiceAccountContent($file)->getToken();
$chatter = new Chatter(new FirebaseTransport($token));
$chatMessage = new ChatMessage('super text');
$options = new TargetMessageOptions(
token: '....',
common: new CommonNotification(
title: 'incident title',
body: 'test message',
),
android: new AndroidNotification(
clickAction: 'open_incident_view',
),
data: [
'id' => '54841',
'type' => 'incident',
'title' => 'incident title',
'message' => 'incident message',
],
);
// Add the custom options to the chat message and send the message
$chatMessage->options($options);
try {
$chatter->send($chatMessage);
} catch (TransportException $exception) {
echo $exception->getMessage();
}
```