PHPackages                             basharat78/nativephp-local-notification - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. basharat78/nativephp-local-notification

ActiveNativephp-plugin[Mail &amp; Notifications](/categories/mail)

basharat78/nativephp-local-notification
=======================================

WhatsApp-style local notifications with sound for NativePHP Mobile (iOS &amp; Android)

v1.0.0(1mo ago)02MITSwiftPHP ^8.1

Since Apr 15Pushed 1mo agoCompare

[ Source](https://github.com/basharat78/nativephp-local-notification)[ Packagist](https://packagist.org/packages/basharat78/nativephp-local-notification)[ RSS](/packages/basharat78-nativephp-local-notification/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

NativePHP Local Notification Plugin
===================================

[](#nativephp-local-notification-plugin)

WhatsApp-style local notifications with sound, badge, and tap handling for **NativePHP Mobile v3** — works on both **iOS** and **Android**.

---

Features
--------

[](#features)

- ✅ Show notifications immediately or scheduled
- ✅ Custom / default sound (plays even in foreground, like WhatsApp)
- ✅ App icon badge count
- ✅ Tap &amp; dismiss events dispatched to PHP / Livewire
- ✅ Android notification channels (API 26+)
- ✅ Notification grouping
- ✅ Permission request &amp; check
- ✅ Cancel individual or all notifications
- ✅ JavaScript bridge for Vue / React / Livewire

---

Installation
------------

[](#installation)

### 1. Require the package

[](#1-require-the-package)

```
composer require basharat78/nativephp-local-notification
```

### 2. Register the plugin

[](#2-register-the-plugin)

```
php artisan vendor:publish --tag=nativephp-plugins-provider   # first time only
php artisan native:plugin:register basharat78/nativephp-local-notification
```

### 3. Rebuild native projects

[](#3-rebuild-native-projects)

```
php artisan native:install --force
php artisan native:run android   # or ios
```

---

PHP Usage
---------

[](#php-usage)

### Show a notification

[](#show-a-notification)

```
use Basharat78\LocalNotification\Facades\LocalNotification;

// Simple
LocalNotification::show('New Message', 'Hey, how are you?');

// With options
LocalNotification::show('New Message', 'Hey, how are you?', [
    'id'        => 'msg_42',
    'sound'     => 'default',        // 'default' | 'none' | 'custom_sound'
    'badge'     => 3,
    'channelId' => 'messages',       // Android only
    'data'      => ['chat_id' => 5], // passed back in NotificationTapped event
    'priority'  => 'high',
]);

// Scheduled (10 minutes from now)
LocalNotification::show('Reminder', 'Don\'t forget!', [
    'scheduleAt' => now()->addMinutes(10)->timestamp,
]);
```

### Request / check permission

[](#request--check-permission)

```
$result = LocalNotification::requestPermission();
// ['granted' => true, 'status' => 'granted']

$result = LocalNotification::checkPermission();
// ['granted' => true, 'status' => 'granted']
```

### Manage notifications

[](#manage-notifications)

```
LocalNotification::cancel('msg_42');   // cancel one
LocalNotification::cancelAll();        // cancel all
LocalNotification::setBadge(0);        // clear badge
```

### Android channels (set up once at app start)

[](#android-channels-set-up-once-at-app-start)

```
// In AppServiceProvider::boot() or a lifecycle hook
LocalNotification::createChannel(
    id:          'messages',
    name:        'Messages',
    importance:  'high',
    description: 'New message notifications',
    sound:       true,
    vibration:   true,
    lights:      true,
);
```

---

Listening for Events
--------------------

[](#listening-for-events)

Register listeners in `EventServiceProvider`:

```
use Basharat78\LocalNotification\Events\NotificationTapped;
use Basharat78\LocalNotification\Events\NotificationDismissed;
use Basharat78\LocalNotification\Events\NotificationPermissionChanged;

protected $listen = [
    NotificationTapped::class => [
        \App\Listeners\HandleNotificationTap::class,
    ],
    NotificationDismissed::class => [
        \App\Listeners\HandleNotificationDismiss::class,
    ],
    NotificationPermissionChanged::class => [
        \App\Listeners\HandlePermissionChange::class,
    ],
];
```

Example listener:

```
class HandleNotificationTap
{
    public function handle(NotificationTapped $event): void
    {
        // $event->id   — the notification ID
        // $event->data — your custom payload array
        // e.g. redirect to the right chat screen
    }
}
```

In **Livewire**, you can listen directly on a component:

```
#[On(NotificationTapped::class)]
public function onNotificationTapped(string $id, array $data): void
{
    // handle tap
}
```

---

JavaScript Usage
----------------

[](#javascript-usage)

```
import LocalNotification from './localNotification.js';

// Check / request permission
const { granted } = await LocalNotification.checkPermission();
if (!granted) {
    await LocalNotification.requestPermission();
}

// Show a notification
await LocalNotification.show('New Message', 'Hey!', {
    sound:     'default',
    badge:     1,
    channelId: 'messages',
    data:      { chatId: 5 },
});

// Clear badge on app open
await LocalNotification.setBadge(0);
```

---

Custom Sound Files
------------------

[](#custom-sound-files)

### Android

[](#android)

Place your `.mp3` or `.wav` file in `android/app/src/main/res/raw/` (e.g. `message_sound.mp3`), then:

```
LocalNotification::show('New Message', 'Hey!', ['sound' => 'message_sound']);
```

### iOS

[](#ios)

Add your sound file to the Xcode project (e.g. `message_sound.caf`), then:

```
LocalNotification::show('New Message', 'Hey!', ['sound' => 'message_sound.caf']);
```

---

Permissions
-----------

[](#permissions)

### Android

[](#android-1)

The following permissions are declared automatically via the manifest:

- `android.permission.POST_NOTIFICATIONS` — runtime permission on Android 13+ (API 33)
- `android.permission.VIBRATE`
- `android.permission.RECEIVE_BOOT_COMPLETED`

### iOS

[](#ios-1)

The following `Info.plist` key is added automatically:

- `NSUserNotificationsUsageDescription`

---

Testing
-------

[](#testing)

```
php artisan native:plugin:validate basharat78/nativephp-local-notification
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance89

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

55d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/73368d4b7bb3e2e0c10af5c9c0efef53757768248640725bf621f0827cb8f87a?d=identicon)[basharat78](/maintainers/basharat78)

---

Top Contributors

[![basharat78](https://avatars.githubusercontent.com/u/110536706?v=4)](https://github.com/basharat78 "basharat78 (5 commits)")[![Princessdada](https://avatars.githubusercontent.com/u/106841602?v=4)](https://github.com/Princessdada "Princessdada (5 commits)")

### Embed Badge

![Health badge](/badges/basharat78-nativephp-local-notification/health.svg)

```
[![Health](https://phpackages.com/badges/basharat78-nativephp-local-notification/health.svg)](https://phpackages.com/packages/basharat78-nativephp-local-notification)
```

###  Alternatives

[mattketmo/email-checker

Throwaway email detection library

2742.1M5](/packages/mattketmo-email-checker)[ifightcrime/bootstrap-growl

Pretty simple jQuery plugin that turns standard Bootstrap alerts into 'Growl-like' notifications.

80113.0k](/packages/ifightcrime-bootstrap-growl)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)[andheiberg/notify

A site notification package for laravel.

119.1k1](/packages/andheiberg-notify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
