pteal79/native-notification

A NativePHP plugin for dispatching native notifications via OnNative events

Maintainers

Package info

github.com/pteal79/native-notification

Type:nativephp-plugin

pkg:composer/pteal79/native-notification

Statistics

Installs: 14

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.2 2026-04-21 17:37 UTC

This package is auto-updated.

Last update: 2026-04-21 17:38:17 UTC


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