Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification Event #465

Open
connor-devuk opened this issue Jan 10, 2025 · 5 comments
Open

Notification Event #465

connor-devuk opened this issue Jan 10, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@connor-devuk
Copy link

What were you trying to do?

I'm trying to make a notfication have a custom click event: Notification::title('Team Call')
->message('Hey just a little reminder a team call is about to start!')
->event(\App\Events\OpenTeamCallEvent::class)
->show(); like so however when clicking it an internal server error happens

Only arrays and Traversables can be unpacked

This seems to be related to livewire however no variables should be passed so not too sure whats going on

This is my event

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;

class OpenTeamCallEvent implements ShouldBroadcastNow
{
    public function broadcastOn(): array
    {
        return [
            new Channel('nativephp')
        ];
    }
}

What happened?

Clicking an event from a notification it throws the error Only arrays and Traversables can be unpacked

How to reproduce the bug

Notification::title('Team Call')
->message('Hey just a little reminder a team call is about to start!')
->event(\App\Events\OpenTeamCallEvent::class)
->show();

Package Versions

{
"installed": [
{
"name": "nativephp/electron",
"direct-dependency": true,
"homepage": "https://github.com/nativephp/electron",
"source": "https://github.com/NativePHP/electron/tree/0.9.0",
"version": "0.9.0",
"description": "Electron wrapper for the NativePHP framework.",
"abandoned": false
},
{
"name": "nativephp/laravel",
"direct-dependency": false,
"homepage": "https://github.com/nativephp/laravel",
"source": "https://github.com/NativePHP/laravel/tree/0.7.0",
"version": "0.7.0",
"description": "Laravel wrapper for the NativePHP framework.",
"abandoned": false
},
{
"name": "nativephp/php-bin",
"direct-dependency": false,
"homepage": "https://nativephp.com",
"source": "https://github.com/NativePHP/php-bin/tree/0.5.6",
"version": "0.5.6",
"description": "PHP binaries used by the NativePHP framework",
"abandoned": false
}
]
}

PHP Version

8.3

Laravel Version

11.37

Node Version

22.11.0

Which operating systems have you seen this occur on?

macOS

OS version

15.1 (24B83)

Notes

No response

@connor-devuk connor-devuk added the bug Something isn't working label Jan 10, 2025
@connor-devuk
Copy link
Author

its worth noting when i call this event from a controller or my scheduler etc it works, its only when its called via the Notfication->event method

@JA-Developer
Copy link
Contributor

I reproduced the error:

Image

It seems that the problem is in the file vendor\nativephp\electron\resources\js\electron-plugin\dist\server\api\notification.js

    notification.on("click", (event) => {
        notifyLaravel('events', {
            event: eventName,
            payload: JSON.stringify(event)
        });
    });

The functions 'notifyLaravel' expects for an array payload. And, a string payload is passed.

@simonhamp
Copy link
Member

@JA-Developer are you running the same package versions as @connor-devuk ?

@JA-Developer
Copy link
Contributor

Hi @simonhamp. Yes. It's the same version.

nativephp/electron 0.9.0 Electron wrapper for the NativePHP framework.
nativephp/laravel 0.7.0 Laravel wrapper for the NativePHP framework.
nativephp/php-bin 0.5.6 PHP binaries used by the NativePHP framework

@simonhamp
Copy link
Member

I believe this issue is fixed in the 1.0 betas. Please try updating to those and test this again.

If it's still an issue, please report back.

@simonhamp simonhamp self-assigned this Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants