pteal79 / native-notification
A NativePHP plugin for dispatching native notifications via OnNative events
Package info
github.com/pteal79/native-notification
Type:nativephp-plugin
pkg:composer/pteal79/native-notification
1.0.2
2026-04-21 17:37 UTC
Requires
- php: ^8.2
- nativephp/mobile: ^3.0
Requires (Dev)
- pestphp/pest: ^3.0
README
Dispatches a NativeNotification event through the native layer via a single SendNotification bridge call. The event carries a nullable string payload and can be consumed in PHP with #[OnNative].
Installation
composer require pteal79/native-notification php artisan vendor:publish --tag=nativephp-plugins-provider php artisan native:plugin:register pteal79/native-notification php artisan native:plugin:list
Usage
PHP (Livewire/Blade)
use PTeal79\NativeNotification\Facades\NativeNotification; NativeNotification::sendNotification('Hello world!'); NativeNotification::sendNotification(null);
Listening for the Event
use Native\Mobile\Attributes\OnNative; use PTeal79\NativeNotification\Events\MobileEvent; #[OnNative(MobileEvent::class)] public function handleNativeNotification(?string $message): void { // $message is the string passed to sendNotification() }
JavaScript
import { NativeNotification, Events } from '@pteal79/native-notification'; import { on, off } from '@nativephp/native'; await NativeNotification.sendNotification('Hello!'); const handler = (payload) => console.log(payload.message); on(Events.MobileEvent, handler); off(Events.MobileEvent, handler);
Events
| Event | Payload | Description |
|---|---|---|
MobileEvent |
{ message: string|null } |
Dispatched by the native layer when sendNotification is called |
License
MIT