CarNotification.php;
`class CarNotifications extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct()
{
}
public function fcmProject($notifiable, $message)
{
// $message is what is returned by `toFcm`
return 'app'; // name of the firebase project to use
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via($notifiable)
{
return [FcmChannel::class];
}
public function toFcm($notifiable)
{
return FcmMessage::create()
->setData(['data1' => 'value', 'data2' => 'value2'])
->setNotification(\NotificationChannels\Fcm\Resources\Notification::create()
->setTitle('Account Activated')
->setBody('Your account has been activated.')
->setImage('http://example.com/url-to-image-here.png'));
} `
User model;
class User extends Authenticatable implements MustVerifyEmail { use HasApiTokens, HasFactory, Notifiable, HasPushSubscriptions; ..... public function routeNotificationForFcm() { return $this->getDeviceTokens(); } ...
NotificationSendBlade;
`new class extends Component {
public function sendNotification()
{
$user = Auth::user();
$user->notify(new CarNotifications());
}
I followed docs but it's not work..
CarNotification.php; `class CarNotifications extends Notification { use Queueable;
User model;
class User extends Authenticatable implements MustVerifyEmail { use HasApiTokens, HasFactory, Notifiable, HasPushSubscriptions; ..... public function routeNotificationForFcm() { return $this->getDeviceTokens(); } ...
}; ?>`
.env
FIREBASE_CREDENTIALS=storage/app/arabag-app-70184ee02367.json