PHPackages                             denis156/fcm-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. denis156/fcm-notification

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

denis156/fcm-notification
=========================

Plugin NativePHP untuk integrasi Firebase Cloud Messaging (FCM) dan pengambilan token notifikasi perangkat.

1.0.2(1mo ago)261MITPHPPHP ^8.3

Since May 6Pushed 1mo agoCompare

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

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

NativePHP FCM Notification Plugin (v3)
======================================

[](#nativephp-fcm-notification-plugin-v3)

[![PHP Version](https://camo.githubusercontent.com/ce1068cd9f78ad2a081449d7e46efb2a2da1ff161c1c5aad703f27366a985ecc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d3737376262343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/)[![Laravel Version](https://camo.githubusercontent.com/e7e8d925e0671ce7f284ff2af4571db768c1b074e60dedcf1c9635066e6ac695/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312e7825323025324625323031332e782d4646324432303f6c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://laravel.com)[![NativePHP](https://camo.githubusercontent.com/d3fbf228d39a2cd6443b67d238dcb38f3a2bdf6d3291378cab5b36b74aa616e1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e61746976655048502d76332d346634366535)](https://nativephp.com)[![Firebase FCM](https://camo.githubusercontent.com/50c5fc64d0232ab9a4c5e36c624632e059c4a56da52c506b38fdd1fdcb89709b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f46697265626173652d46434d2d6666636132383f6c6f676f3d6669726562617365266c6f676f436f6c6f723d626c61636b)](https://firebase.google.com/docs/cloud-messaging)[![Platform Android](https://camo.githubusercontent.com/c101d2fc2bfddc9d93bd990d3065106cf6e80b48ba7ee8a89b0b0585b0095080/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506c6174666f726d2d416e64726f69642d3344444338343f6c6f676f3d616e64726f6964266c6f676f436f6c6f723d7768697465)](https://developer.android.com/)[![Author](https://camo.githubusercontent.com/2e6ff2b4196424087f8eb41bcce18db1921588342dc41823bff29618814d2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f417574686f722d64656e69733135362d626c75653f6c6f676f3d676974687562)](https://github.com/denis156)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Plugin open-source untuk mengintegrasikan Firebase Cloud Messaging (FCM) ke dalam aplikasi mobile NativePHP khusus untuk **Android**. Memungkinkan pengambilan token perangkat secara unik dan penanganan izin notifikasi secara otomatis mengikuti standar arsitektur **NativePHP Mobile v3**.

Fitur Unggulan
--------------

[](#fitur-unggulan)

- **Manajemen Izin Real-time**: Mengecek status 'saklar' notifikasi di semua versi Android secara akurat.
- **Auto-dialog (Android 13+)**: Memicu dialog permintaan izin `POST_NOTIFICATIONS` secara runtime sesuai kebijakan Google terbaru.
- **Bypass ke Pengaturan**: Membuka halaman pengaturan aplikasi langsung jika izin ditolak atau ingin dikonfigurasi manual.
- **Pengambilan Token FCM**: Mengambil registrasi token unik dengan penanganan error yang kuat.
- **Otomatisasi Aset**: Hook bawaan untuk menyalin file kredensial (`google-services.json`) ke folder build native.
- **V3 Bridge Standards**: Menggunakan struktur direktori `resources/` yang kompatibel dengan NativePHP Plugin Kit.

Instalasi
---------

[](#instalasi)

Tambahkan plugin ke proyek Laravel Anda melalui Composer:

```
composer require denis156/fcm-notification
```

Daftarkan plugin di proyek NativePHP Anda untuk mengaktifkan integrasi native:

```
php artisan native:plugin:register denis156/fcm-notification
```

Persiapan Firebase
------------------

[](#persiapan-firebase)

### 1. File Konfigurasi

[](#1-file-konfigurasi)

Plugin ini menggunakan hook `copy_assets` untuk menyalin file konfigurasi Firebase Anda ke target native secara otomatis. Letakkan file kredensial Anda di folder `firebase/` pada root proyek:

- Android: `firebase/google-services.json`

### 2. Update Proyek

[](#2-update-proyek)

Pastikan `Application ID` di file `.env` sudah sama dengan yang terdaftar di Firebase Console:

```
NATIVEPHP_APP_ID=com.example.app
```

Jalankan build untuk memicu penyalinan file dan kompilasi plugin:

```
php artisan native:run android
```

Penggunaan
----------

[](#penggunaan)

### Sisi PHP (Laravel/Inertia/Livewire)

[](#sisi-php-laravelinertialivewire)

Gunakan facade `FcmNotification` untuk berinteraksi dengan layanan native:

```
use Denis156\FcmNotification\Facades\FcmNotification;

// 1. Cek status izin saat ini ('granted' atau 'denied')
$status = FcmNotification::getStatus();

// 2. Minta izin notifikasi (Dialog popup pada Android 13+)
if ($status !== 'granted') {
    FcmNotification::requestPermission();
}

// 3. Buka halaman pengaturan aplikasi (Jika user menolak izin sebelumnya)
FcmNotification::openSettings();

// 4. Mengambil Token FCM untuk dikirim ke backend
$token = FcmNotification::getToken();
```

### Sisi JavaScript (Vue/React/Inertia)

[](#sisi-javascript-vuereactinertia)

Anda juga bisa memanggil fungsi native langsung dari frontend:

```
import { fcmNotification } from '@denis156/fcm-notification';

// Ambil status izin
const status = await fcmNotification.getStatus();

// Buka pengaturan
await fcmNotification.openSettings();

// Ambil token
const token = await fcmNotification.getToken();
```

Panduan Debugging
-----------------

[](#panduan-debugging)

Jika token tidak muncul atau status izin selalu `denied`:

1. **Pantau Log Native**: Gunakan `php artisan native:tail` untuk melihat aktivitas bridge.
2. **Detail Log Android**: Gunakan `adb logcat -s FCM_PLUGIN` untuk melihat debugging level native (Kotlin).
3. **Reset Token Lokal**: Gunakan Tinker untuk menghapus token lama agar plugin memicu pengambilan ulang: ```
    php artisan tinker --execute 'App\Models\AppSession::query()->update(["fcm_token" => null]);'
    ```

Struktur Direktori (Standar v3)
-------------------------------

[](#struktur-direktori-standar-v3)

```
packages/denis156/fcm-notification/
├── nativephp.json          # Manifest Plugin & Bridge Functions
├── src/                    # Kode PHP (Service Provider, Facade, Command)
└── resources/
    ├── android/src/        # Kode Kotlin (Bridge Implementation)
    └── boost/guidelines/   # Instruksi spesifik untuk AI assistants

```

Kontributor
-----------

[](#kontributor)

Dikembangkan dengan penuh dedikasi oleh [denis156](https://github.com/denis156).

Lisensi
-------

[](#lisensi)

[MIT License](LICENSE)

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance94

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Every ~1 days

Total

3

Last Release

33d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

1.0.2PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/5195b9f01c0fbce97c71c6437c1a3745af9b41d02866e644d27872b36f1b8bcc?d=identicon)[denis156](/maintainers/denis156)

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/denis156-fcm-notification/health.svg)

```
[![Health](https://phpackages.com/badges/denis156-fcm-notification/health.svg)](https://phpackages.com/packages/denis156-fcm-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)
