I've implemented pusher beams like this:
- I've added credentials in
config/services.php
'pusher' => [
'beams_instance_id' => '********',
'beams_secret_key' => '*************',
],
- I've created a new notification
class TestOne extends Notification
{
use Queueable;
public $message;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [PusherChannel::class , 'database'];
}
/**
* Get the array representation of the notification.
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
// event( new PostLiked($notifiable->id ,$this->message));
return [
'title' => $this->message->title,
'content' => $this->message->content,
];
}
// notification type
public function broadcastType()
{
return 'users';
}
public function toPushNotification($notifiable)
{
return PusherMessage::create()
->platform('web')
->badge(1)
->sound('success')
->body("Your ac account was approved!");
}
}
- I've added Notifiable to User Model :
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
How to specify the interest in my backend so I can listen to it in my react app and how to use beams debug console to make sure the Laravel notification is being fired?