1. Go to this page and download the library: Download andriichuk/pushbox 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/ */
andriichuk / pushbox example snippets
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use NotificationChannels\Fcm\FcmChannel;
use NotificationChannels\Fcm\FcmMessage;
use NotificationChannels\Fcm\Resources\Notification as FcmNotification;
class WelcomePush extends Notification
{
public function via(object $notifiable): array
{
return [FcmChannel::class];
}
public function toFcm(object $notifiable): FcmMessage
{
return new FcmMessage(
notification: new FcmNotification(
title: __('Welcome'),
body: 'Hello '.($notifiable->name ?? 'developer').'!',
),
data: ['screen' => 'welcome'], // FCM data values must be strings.
);
}
}
use Andriichuk\Pushbox\Facades\Pushbox;
use App\Notifications\WelcomePush;
Pushbox::add(WelcomePush::class);
use App\Models\User;
Pushbox::to(User::factory()->make(['name' => 'Ada']))
->category('Onboarding')
->group(function () {
Pushbox::add(WelcomePush::class)
->variant('Another greeting', fn (): WelcomePush => new WelcomePush);
});