Closed Myestery closed 4 years ago
Hi there,
Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:
However, this issue will not be locked and everyone is still free to discuss solutions to your problem!
Thanks.
I finally solved this issue myself
Steps
In my bootstrap.js file
window.Echo = new Echo({
broadcaster: "pusher",
key: "my key",
cluster: "eu",
encrypted: true,
authEndpoint: "api/broadcasting/auth",
auth: {
headers: {
Authorization: "Bearer " + localStorage.getItem("token"),
},
},
});
Then in my routes/api.php file,
Route::middleware('auth:api')->post('broadcasting/auth', function (Request $request) {
$pusher = new Pusher\Pusher(
$app_key,
$app_secret,
$app_id
);
return $pusher->socket_auth($request->request->get('private-my-channel'),($request->request->get('socket_id'));
});
There is more info on this in the documentation, I hope it helps someone someday
@Myestery on next version you can use bearerToken
option
window.Echo = new Echo({
broadcaster: "pusher",
key: "my key",
cluster: "eu",
encrypted: true,
authEndpoint: "api/broadcasting/auth",
bearerToken: localStorage.getItem("token"),
/*auth: {
headers: {
Authorization: "Bearer " + localStorage.getItem("token"),
},
},*/
});
@Myestery on next version you can use
bearerToken
optionwindow.Echo = new Echo({ broadcaster: "pusher", key: "my key", cluster: "eu", encrypted: true, authEndpoint: "api/broadcasting/auth", bearerToken: localStorage.getItem("token"), /*auth: { headers: { Authorization: "Bearer " + localStorage.getItem("token"), }, },*/ });
Thanks
Description: I'm trying to send notifications to users,
My pusher connection is good because it sends on public channels And also, i get this message on my console
[2020-07-24 21:08:09][355] Processed: Illuminate\Notifications\Events\BroadcastNotificationCreated
and on pusher i also see that the message was sent. I also don't get any errors on my browser console as all the websocket connections are working well. But i still dont get any messages. I triedI also tried
I also followed many tutorials and the docs All to no avail.
Steps To Reproduce:
Create a notification and declare both the toArray method and toBroadcast methods but echo fails to catch messages from pusher