Created
November 19, 2020 16:49
-
-
Save razvanstatescu/88729abf039a7069764c59144e4d3202 to your computer and use it in GitHub Desktop.
Pusher Channels example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Pusher = require("pusher"); | |
const pusher = new Pusher({ | |
appId: "APP_ID", | |
key: "APP_KEY", | |
secret: "APP_SECRET", | |
cluster: "APP_CLUSTER" | |
}); | |
pusher.trigger("user-123", "notifications", { | |
message: "hello world" | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Pusher Example</title> | |
<script src="https://js.pusher.com/7.0/pusher.min.js"></script> | |
</head> | |
<body> | |
<script> | |
const pusher = new Pusher('APP_KEY', { | |
cluster: 'APP_CLUSTER' | |
}); | |
const channel = pusher.subscribe('user-123'); | |
channel.bind('notifications', data => { | |
alert('New Notification: ' + data.message); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment