PHP code example of tomatophp / filament-fcm

1. Go to this page and download the library: Download tomatophp/filament-fcm 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/ */

    

tomatophp / filament-fcm example snippets


->plugin(\TomatoPHP\FilamentFcm\FilamentFcmPlugin::make()
)

use Filament\Notifications\Notification;

Notification::make('send')
    ->title('Test Notifications')
    ->body('This is a test notification')
    ->icon('heroicon-o-bell')
    ->color('success')
    ->actions([
    \Filament\Notifications\Actions\Action::make('view')
        ->label('View')
        ->url('https://google.com')
        ->markAsRead()
    ])
    ->sendToFCM(
        user: auth()->user(),
        data: [
            'key' => 'value'
        ],
        sendToDatabase: false,
        type: 'fcm-web' // or fcm-api
    )


$user->notifyFCMSDK(
    message: $this->message,
    type: $this->provider,
    title: $this->title,
    url: $this->url,
    image: $this->image,
    icon: $this->icon,
    data: [
        'url' => $this->url,
        'id' => $this->model_id,
        'actions' => [],
        'body' => $this->message,
        'color' => null,
        'duration' => null,
        'icon' => $this->icon,
        'iconColor' => null,
        'status' => null,
        'title' => $this->title,
        'view' => null,
        'viewData' => null,
        'data'=> $this->data
    ],
    sendToDatabase: false
);

bash
php artisan config:clear
bash
php artisan filament-fcm:install
bash
php artisan vendor:publish --tag="filament-fcm-config"
bash
php artisan vendor:publish --tag="filament-fcm-views"
bash
php artisan vendor:publish --tag="filament-fcm-migrations"