I am using "minishlink/web-push" package to send notification in my Laravel project.
Route::post("/admin/sendNotif/{sub}", function(PushSubscription $sub, Request $request){
$webPush = new WebPush([
"VAPID" => [
"publicKey" => "BNbqX8M5NJJ...",
"privateKey" => "i4I89hSrn-MGvp...",
"subject" => "https://example.com"
]
]);
$webPush->sendOneNotification(
Subscription::create(json_decode($sub->data, true)),
json_encode($request->input())
);
return redirect("/");
});
With this method, I can send only one notification:
$webPush->sendOneNotification(
Subscription::create(json_decode($sub->data, true)),
json_encode($request->input())
);
Is there a way I can send multiple notifications at the same time?
2
Answers
Because this package uses Google service, I doubt it can do this. My suggestion is that you use Laravel echo : https://github.com/laravel/echo
Have a look at this readme for a better explanation of WebPush:
web-push-php
Code Snippet
Explanation