Open NicoCascella opened 5 months ago
use it as below, as in laravel 10 and 11 it is not triggering as in docs.
public function toPushNotification($notifiable)
{
$beamsClient = new \Pusher\PushNotifications\PushNotifications([
'instanceId' => config('services.pusher.beams_instance_id'),
'secretKey' => config('services.pusher.beams_secret_key'),
]);
$publishResponse = $beamsClient->publishToInterests(
['App.User.'.$notifiable->id],
['web' => [
'notification' => [
'title' => 'New Customer Registered!',
'body' => "{$this->customerName} has been registered to the system!",
],
],
]);
return $publishResponse;
}
it does not work for me either and we need it in our company.
We are using laravel 11,livewire3 , pusher beams. Can you please copy-paste the whole code that is relative to beams (front-end,back-end) so as to see what's the right way? i would greatly appreciate it .
Spyridon
use it as below, as in laravel 10 and 11 it is not triggering as in docs.
public function toPushNotification($notifiable) { $beamsClient = new \Pusher\PushNotifications\PushNotifications([ 'instanceId' => config('services.pusher.beams_instance_id'), 'secretKey' => config('services.pusher.beams_secret_key'), ]); $publishResponse = $beamsClient->publishToInterests( ['App.User.'.$notifiable->id], ['web' => [ 'notification' => [ 'title' => 'New Customer Registered!', 'body' => "{$this->customerName} has been registered to the system!", ], ], ]); return $publishResponse; }
I'm trying to use pusher-push-notifications in Laravel 11, with a Vue 3 SPA, in a separate project. If I try to make the call with a Curl or an Http request, the notification is successful. The problem arises when I try to use the pusher-push-notifications functionalities.
` $user = \App\Models\User::find(136); $notifica = 'notifica'; try { // $user->notify( new TestNotification($notifica)); \Illuminate\Support\Facades\Notification::send(User::all(), new TestNotification($notifica));
namespace App\Notifications; use NotificationChannels\PusherPushNotifications\PusherChannel; use NotificationChannels\PusherPushNotifications\PusherMessage;
use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification;
class TestNotification extends Notification { public $notifica; /**
Create a new notification instance. */ public function __construct($notifica) { $this->notifica = $notifica; }
/**
@return array<int, string> */ public function via(object $notifiable): array { return [PusherChannel::class ]; }
public function toPushNotification($notifiable) {
} }
` Basically, the notification's via() method doesn't lead me to the next toPushNotification and therefore doesn't send the notification. Does anyone have any solutions?