Push notifications are the feature nobody notices until they stop working. On a delivery platform I rebuilt, drivers were missing job assignments and customers were missing "your quote is ready" alerts, and the symptom was always the same: the backend logged a successful send and the phone stayed silent. If you are searching for why your Laravel FCM HTTP v1 pushes never arrive, the honest answer is that there is rarely one cause. There were three separate ones on this project, and fixing only the loudest would have left the platform half-broken.
This article walks through what I found on the ION DASH logistics and fleet platform, the Laravel code I ended up with, and the places where I deliberately did not use a package. It is the kind of API work I do under API development and integrations, where "the call returned 200" is the start of the investigation, not the end.
Three failures that looked like one bug
ION DASH was a legacy delivery app being rebuilt as Flutter customer and driver apps on a Laravel API. The old notification flow was unreliable on modern Android devices. When I traced it, "unreliable" was hiding three independent problems:
| # | Layer | What was wrong | How it showed up |
|---|---|---|---|
| 1 | Backend to Google | The notification pipeline had to move to the FCM HTTP v1 API with service-account authentication | Sends relied on an older integration path Google has been retiring |
| 2 | Payload | Messages needed Android-safe payloads: a channel, explicit priority, string-only data values | Payloads not tailored to Android could be dropped, delayed or deprioritised |
| 3 | The device | Android 13+ treats notifications as a runtime permission, and the app was not asking for it | Backend and Google both succeeded, the user saw nothing |
The third one is the trap. No amount of server-side work fixes it, and no server-side log tells you it is happening. Google's own documentation states that Android 13 introduced the POST_NOTIFICATIONS runtime permission, and that until the user grants it your app cannot show most notifications. I had to fix it in the Flutter app by requesting the permission in context, and by creating proper notification channels, before any backend change mattered.
Important: If a push is accepted by FCM but never appears, check the device before you check your server. On Android 13 and later, a missing notification permission looks exactly like a backend bug.
Moving to the HTTP v1 API with a service account
The legacy FCM HTTP API authenticated with a static server key. The current API is different in two ways that matter to a Laravel developer: the endpoint is project-scoped (POST https://fcm.googleapis.com/v1/projects/{project-id}/messages:send), and every request carries a short-lived OAuth 2.0 access token minted from a service-account key, with the scope https://www.googleapis.com/auth/firebase.messaging, as described in Google's HTTP v1 send documentation.
That short-lived token is the part people get wrong. The access token lasts about an hour. If you mint a new one for every notification you add a round trip to Google's auth server in front of every push, and you will feel it the first time you notify a few hundred drivers at once. Cache it.
The code below is a simplified version of the pattern I used (not client code). I wrapped the token in a small class instead of pulling in a full notification package:
<?php namespace App\Services\Push; use Google\Auth\Credentials\ServiceAccountCredentials; use Illuminate\Support\Facades\Cache; class FcmAccessToken { private const SCOPE = 'https://www.googleapis.com/auth/firebase.messaging'; public function get(): string { // Token is valid for ~1 hour; refresh a little early. return Cache::remember('fcm.access_token', now()->addMinutes(50), function () { $credentials = new ServiceAccountCredentials( self::SCOPE, json_decode(file_get_contents(config('services.fcm.credentials_path')), true) ); return $credentials->fetchAuthToken()['access_token']; }); } } Two details I would not skip. First, the credentials file path lives in config and the file itself is outside the web root and outside the repository; it is a secret with project-wide send rights. Second, the cache key must live in a shared store (Redis or database), not the array driver, or every queue worker will mint its own token. If you are deciding on a cache layer, my Redis caching architecture article covers the trade-offs.
A payload Android will actually honour
With HTTP v1, a message is a JSON envelope with a target (a device token, a topic or a condition) and platform-specific blocks. The shape I settled on for driver and customer alerts looked like this:
$payload = [ 'message' => [ 'token' => $device->fcm_token, 'notification' => [ 'title' => $title, 'body' => $body, ], // FCM requires every data value to be a string. 'data' => array_map('strval', [ 'type' => 'delivery_assigned', 'delivery_id' => $delivery->id, 'notification_id' => $record->id, ]), 'android' => [ 'priority' => 'HIGH', 'notification' => [ 'channel_id' => 'dispatch_alerts', ], ], ], ]; Three choices are doing real work here:
-
channel_idmust match a channel the app created. On Android 8 and later, a notification sent to a channel that does not exist can be dropped or land in a default channel the user has muted. -
priority: HIGHis reserved for things that are genuinely time-sensitive. A driver assignment qualifies. A marketing nudge does not, and abusing high priority tends to get you deprioritised. -
notification_idinsidedataties the push back to a row in my database, which becomes important in the next section.
Cast data values with strval. FCM expects string values in data, and a non-string value can come back as INVALID_ARGUMENT, the same error code you can get for a bad token, so it is easy to misdiagnose.
Persist first, send second, treat errors as data
The most useful decision on this project was boring: every notification is saved to a notifications table before anything is sent, and the send happens in a queued job.
class SendPushNotification implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable; public int $tries = 3; public array $backoff = [10, 60]; public function __construct(private int $recordId) {} public function handle(FcmClient $fcm): void { $record = PushRecord::with('device')->findOrFail($this->recordId); if ($record->sent_at) { return; // retry after success must not double-send } $result = $fcm->send($record); if ($result->isUnregistered()) { $record->device->delete(); // dead token, stop sending to it $record->update(['status' => 'token_invalid']); return; } $result->throwIfRetryable(); // 429 / 5xx, let the queue retry $record->update(['status' => 'sent', 'sent_at' => now()]); } } This gives you three things a fire-and-forget Http::post never does:
- An audit trail. When a customer says "I never got the quote alert", I can see whether it was created, sent, rejected or never attempted. That conversation used to be a guessing game.
- Idempotent retries. The
sent_atguard means a retried job does not buzz a driver's phone twice. The same thinking applies to any external call, and I go deeper on it in API idempotency keys in Laravel. - Clean token hygiene. With HTTP v1, a registration that no longer exists returns
UNREGISTERED(HTTP 404). Google's token management guidance says to delete those registrations, and it notes that on Android a registration inactive for 270 days is considered expired and rejected. If you never prune, you keep paying a request for every dead device, and your delivery numbers look worse than they are.
The retry classification matters. A 404 UNREGISTERED is permanent, so retrying it is wasted work. A 429 or 5xx is transient, so it should go back on the queue with backoff. If you want the broader pattern for jobs that call flaky third parties, see how I structure Laravel queues for SaaS.
Testing so it stays fixed
Notification bugs are the sort that return months later when someone changes a payload helper. I added regression tests for the cases that had already bitten us, using Http::fake() so no real call leaves the test suite:
it('deletes the device token when FCM says it is unregistered', function () { Http::fake([ 'fcm.googleapis.com/*' => Http::response([ 'error' => ['details' => [['errorCode' => 'UNREGISTERED']]], ], 404), ]); $record = PushRecord::factory()->create(); (new SendPushNotification($record->id))->handle(app(FcmClient::class)); expect($record->device()->exists())->toBeFalse(); }); The regression tests I keep for this cover: payload data values are all strings, the Android channel and priority are present, an unregistered token is removed, a transient failure is retried, and a second run after success sends nothing. The Laravel HTTP client fake makes each of these a few lines. None of these tests can prove the phone shows the notification, which is why the manual device checklist below still exists.
What I would do differently, and when not to hand-roll this
I wrote the client myself because I needed control over persistence, retries and token cleanup, and because the integration is small: one token class, one sender, one job. That is a trade-off, not a rule.
Use a maintained package or the Firebase Admin SDK if:
- you only need basic sends and have no need for a delivery audit table;
- your team will not maintain the code after you leave;
- you also send to iOS or web and want one abstraction across platforms.
Hand-rolling is justified when push is part of your business workflow, as it was for dispatch, where a missed assignment is a missed delivery, and when you want failures to be visible data rather than a log line.
What I would change on a fresh build: record the device's reported notification permission state at registration time. The ION DASH fix was found by testing on real Android 13 devices. If the app reported "permission denied" to the API, the support team could see it immediately instead of discovering it through complaints.
A manual checklist I now run on every mobile project that sends push:
- [ ] Fresh install on an Android 13+ device: is the permission prompt shown in context, and does a push arrive after granting it?
- [ ] Deny the permission, then trigger a push: does the backend record the send as accepted while the user sees nothing (expected), and does the app offer a way to re-enable?
- [ ] App swiped away and in the background: does a high-priority push still arrive?
- [ ] Reinstall the app: is the old token cleaned up after the first
UNREGISTERED? - [ ] Revoke the service account key in a staging project: do failures surface in logs and alerts rather than silently?
Frequently asked questions
Why does FCM return success but the notification never appears?
A successful response means FCM accepted the message, not that the device displayed it. The usual causes are a missing POST_NOTIFICATIONS permission on Android 13+, a notification channel the user muted or the app never created, or an app-level setting that suppresses foreground display.
Do I need the Firebase Admin SDK to use HTTP v1 from Laravel?
No. HTTP v1 is a plain REST API. You need a service-account credential to mint an OAuth access token and an HTTP client to call messages:send. A package is a convenience, not a requirement.
How often should I refresh the FCM access token?
The token is valid for roughly an hour, so I cache it for about 50 minutes in a shared cache store. Minting one per message adds latency and load for no benefit.
What does INVALID_ARGUMENT mean in a v1 response?
It can mean a malformed token or a malformed payload. Check the payload first (for example non-string data values), then the token. Google's documentation says it can signal either.
Key takeaways
- A silent push usually has more than one cause: the API, the payload and the device each need checking.
- Android 13+ needs a runtime notification permission. No backend change can substitute for it.
- Cache the service-account access token in a shared store instead of minting one per send.
- Persist notifications before sending, send from a queue, and make retries idempotent.
- Treat
UNREGISTEREDas a signal to delete the token, and 429/5xx as a signal to retry. - Hand-roll the client only when push is part of your business workflow.
If your app has notifications that are accepted but never seen, I am happy to look at it. You can book a call and we will go through the send path together.
Originally published at aqibjavaid.site.

