/*************************** .env config pusher_app_id Pusher_app_key Pusher_app_secret Pusher_app_cluster
Broadcast_driver=pusher
uncomment broadcast_service_provider
composer require pusher/pusher-php-server "~4.0"
npm install --save laravel-echo pusher-js
create pusher account edit .env file create pusher connections with composer and npm create broadcast channel create event listener
**********************************/
importScripts("http## js.pusher.com/beams/service-worker.js");
<script src="http## js.pusher.com/beams/1.0/push-notifications-cdn.js"></script>## script file content<script>
const beamsClient = new PusherPushNotifications.Client({ instanceId: '281365ea-136b-4f4d-92c3-e83ec5c706c6', });
beamsClient.start() .then(() => beamsClient.addDeviceInterest('hello')) .then(() => console.log('Successfully registered and subscribed!')) .catch(console.error); </script>
curl -H "Content-Type: application/json"
-H "Authorization: Bearer 413E49FA951691F4D6DC2C50DEDB9894F06F0B7395AB662F40F9C1AD5039DAB2"
-X POST "http## 281365ea-136b-4f4d-92c3-e83ec5c706c6.pushnotifications.pusher.com/publish_api/v1/instances/281365ea-136b-4f4d-92c3-e83ec5c706c6/publishes"
-d '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello, world!"}}}'
<!DOCTYPE html>
Publish an event to channel my-channel
with event name my-event
; it will appear below:
- {{message}}