wassafr/push-server
A self-hosted push notification server for Laravel. Register device tokens, manage subscriptions, and deliver notifications via APNs and FCM, with queue support and a simple HTTP API for your apps.
Install the package with Composer and publish any provided configuration:
composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\<Package>\<PackageServiceProvider>"
Configure your Android push credentials in config/ or .env as documented by the package. Then start with the simplest use case: sending a notification to a single device token.
use Davibennun\LaravelPushNotification\Facades\PushNotification;
PushNotification::app('android')
->to('DEVICE_TOKEN')
->send('Hello from Laravel');
First places to look:
src/AndroidPush.php for Android-specific behavior, including the new chunk-size constant.As of 1.0.11, Android pushes to multiple tokens are automatically split into chunks of 750. This is an internal transport detail for most callers, but it changes how many upstream requests are made and how responses should be interpreted.
Use the fluent API for transactional or user-specific notifications:
PushNotification::app('android')
->to($user->device_token)
->send('Your order has shipped');
Pass an array of tokens. The package will split Android recipients into chunks of 750 automatically:
PushNotification::app('android')
->to($tokens)
->send('Maintenance begins at 22:00 UTC');
Do not manually chunk at 750 unless you need custom retry, logging, or partial-failure handling. Let the package handle transport chunking, and handle failures at the chunk level if you need per-batch visibility.
For large audiences, dispatch the send from a queued job rather than inside a web request. This avoids request timeouts and makes retries explicit:
SendAndroidPush::dispatch($tokens, $message);
Inside the job, keep the package call simple and add your own logging around the number of tokens and chunks:
$chunks = array_chunk($tokens, 750);
foreach ($chunks as $index => $chunk) {
Log::info('Sending Android push chunk', [
'chunk' => $index + 1,
'count' => count($chunk),
]);
PushNotification::app('android')
->to($chunk)
->send($message);
}
This pattern is useful when you want per-chunk retries or metrics. If you rely on the package’s built-in chunking, log the total recipient count before the call instead.
Use the package’s payload methods for title, body, sound, badge, data, and platform-specific options. Keep custom data small and serializable. For Android, remember that data payloads and notification payloads behave differently depending on whether the app is foregrounded, backgrounded, or killed.
Mock the underlying HTTP client or facade so tests do not hit FCM/GCM. Assert:
For integration-style tests, use a fake HTTP client and assert the number of requests when sending more than 750 tokens.
1.0.11, a multi-token Android send may have produced a single upstream request. Now it produces multiple requests in chunks of 750. If your code parses the return value as one response, update it to handle multiple chunk responses or handle chunking yourself.AndroidPush class. Changing it requires a code change, not a config edit. Treat it as an implementation detail unless you have a strong reason to override it.How can I help you explore Laravel packages today?