Tilly The Coder
Tilly The Coder
NativePHP + Livewire Push Notifications (Mobile): A Complete, Copy-Paste Tutorial
Tilly The Coder

NativePHP + Livewire Push Notifications (Mobile): A Complete, Copy-Paste Tutorial

Tilly The Coder
10 mins
This is the estimated time it takes to read the article.

Push notifications in NativePHP for Mobile are powered by Firebase Cloud Messaging (FCM) on both iOS and Android. NativePHP handles the native bits (permissions, token retrieval, firing a Laravel event you can listen to). Your job is to capture and store the device token, then send messages from your server to FCM. This guide walks you through everything with full, drop-in files—no extra SDK required.

What you’ll build

  • A Livewire component that requests push permissions and retrieves the device’s FCM token via NativePHP.

  • A listener for the TokenGenerated native event to store the token in your database.

  • A simple queued job that sends notifications by calling FCM HTTP v1 directly using your Firebase Service Account (minting an OAuth2 access token using plain PHP + Laravel’s HTTP client).

  • A tiny UI to send yourself a test push.

1) Prerequisites & NativePHP install

NativePHP for Mobile targets Laravel 11+ and PHP 8.3+. Add the repo, install, and run the installer.

composer.json (ensure the repository is present)

{
  "name": "example/nativephp-push",
  "type": "project",
  "require": {
    "php&#...
            
The full tutorial is only for premium users.
You can subscribe to one of our plans to access this article. The full tutorial is 2545 words and 10 mins.