PHP code example of emuniq / filament-browser-notifications
1. Go to this page and download the library: Download emuniq/filament-browser-notifications library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emuniq / filament-browser-notifications example snippets
> use NotificationChannels\WebPush\HasPushSubscriptions;
>
> class User extends Authenticatable
> {
> use HasPushSubscriptions, Notifiable;
> }
>
'manifest' => [
'start_url' => '/backoffice', // null = derive from the panel path
'theme_color' => '#10B981', // null = derive from the panel primary color
],
use Emuniq\FilamentBrowserNotifications\BrowserNotificationsPlugin;
->plugins([
BrowserNotificationsPlugin::make()
->promptDelay(5) // seconds before showing prompt (default: 2)
->dismissCooldownDays(14) // days before re-prompting (default: 7)
->profileSection(false), // disable auto-injected profile section
])
Notification::make()
->title('Low priority update')
->body('...')
->viewData(['silent' => true]) // no browser push for this one
->sendToDatabase($users);
bash
php artisan browser-notifications:test 1 # queue the test push
php artisan browser-notifications:test 1 --sync # send immediately