laravel-notification-channels / Webpush

Licence: mit
Webpush notifications channel for Laravel.

Projects that are alternatives of or similar to Webpush

Laravel Fcm
🌐 A Laravel package to send Push Notifications to one or many devices of the user.
Stars: ✭ 56 (-87.19%)
Mutual labels:  laravel, notifications
Facebook
📨 Facebook Notifications Channel for Laravel
Stars: ✭ 120 (-72.54%)
Mutual labels:  laravel, notifications
Notifier
NO LIBRARIES socket per page bridge for your Laravel application. (CLIENT PART INCLUDED)
Stars: ✭ 57 (-86.96%)
Mutual labels:  laravel, notifications
Laravel Smsgateway Notification Channel
SMS Gateway notification channel for Laravel
Stars: ✭ 13 (-97.03%)
Mutual labels:  laravel, notifications
Twilio
Twilio notifications channel for Laravel
Stars: ✭ 141 (-67.73%)
Mutual labels:  laravel, notifications
Builder
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.
Stars: ✭ 1,009 (+130.89%)
Mutual labels:  laravel, notifications
Project
⭐️ Antares Project Application Skeleton. This is the very first place you should start. It allows you to create a brand new awesome project in easy few steps.
Stars: ✭ 84 (-80.78%)
Mutual labels:  laravel, notifications
Larametrics
A self-hosted metrics and notifications platform for Laravel apps
Stars: ✭ 517 (+18.31%)
Mutual labels:  laravel, notifications
Server Monitor App
A PHP application to monitor the health of your servers
Stars: ✭ 141 (-67.73%)
Mutual labels:  laravel, notifications
Health
Laravel Health Panel
Stars: ✭ 1,774 (+305.95%)
Mutual labels:  laravel, notifications
Laravel Notify
Flexible Flash notifications for Laravel
Stars: ✭ 787 (+80.09%)
Mutual labels:  laravel, notifications
Laravel Desktop Notifier
💻 Send notifications to your desktop from your Laravel Artisan Commands. An JoliNotif wrapper for Laravel.
Stars: ✭ 333 (-23.8%)
Mutual labels:  laravel, notifications
Laravel Server Monitor
Don't let your servers just melt down
Stars: ✭ 595 (+36.16%)
Mutual labels:  laravel, notifications
Laravel Notification
Example package for using the (still under development) Messages API from Nexmo as a notification channel in Laravel
Stars: ✭ 44 (-89.93%)
Mutual labels:  laravel, notifications
Laravel Failed Job Monitor
Get notified when a queued job fails
Stars: ✭ 582 (+33.18%)
Mutual labels:  laravel, notifications
Laravel Console Logger
Logging and Notifications for Laravel Console Commands.
Stars: ✭ 79 (-81.92%)
Mutual labels:  laravel, notifications
Snooze
A package to simplify automating future notifications and reminders in Laravel
Stars: ✭ 515 (+17.85%)
Mutual labels:  laravel, notifications
Laravel Fcm
Firebase Cloud Messaging (FCM) sender for Laravel
Stars: ✭ 129 (-70.48%)
Mutual labels:  laravel, notifications
Laravel Slack Slash Command
Make a Laravel app respond to a slash command from Slack
Stars: ✭ 215 (-50.8%)
Mutual labels:  laravel, notifications
Laravel Onesignal
OneSignal Push Notifications for Laravel
Stars: ✭ 369 (-15.56%)
Mutual labels:  laravel, notifications

Web push notifications channel for Laravel

Latest Version on Packagist Build Status Quality Score Code Coverage Total Downloads

This package makes it easy to send web push notifications with Laravel.

Installation

You can install the package via composer:

composer require laravel-notification-channels/webpush

First you must install the service provider (skip for Laravel>=5.5):

// config/app.php
'providers' => [
    ...
    NotificationChannels\WebPush\WebPushServiceProvider::class,
],

Add the NotificationChannels\WebPush\HasPushSubscriptions trait to your User model:

use NotificationChannels\WebPush\HasPushSubscriptions;

class User extends Model
{
    use HasPushSubscriptions;
}

Next publish the migration with:

php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="migrations"

Run the migrate command to create the necessary table:

php artisan migrate

You can also publish the config file with:

php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="config"

Generate the VAPID keys (required for browser authentication) with:

php artisan webpush:vapid

This command will set VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEYin your .env file.

These keys must be safely stored and should not change.

If you still want support Google Cloud Messaging set the GCM_KEY and GCM_SENDER_ID in your .env file.

Usage

Now you can use the channel in your via() method inside the notification as well as send a web push notification:

use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushMessage;
use NotificationChannels\WebPush\WebPushChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

    public function toWebPush($notifiable, $notification)
    {
        return (new WebPushMessage)
            ->title('Approved!')
            ->icon('/approved-icon.png')
            ->body('Your account was approved!')
            ->action('View account', 'view_account')
            ->options(['TTL' => 1000]);
            // ->data(['id' => $notification->id])
            // ->badge()
            // ->dir()
            // ->image()
            // ->lang()
            // ->renotify()
            // ->requireInteraction()
            // ->tag()
            // ->vibrate()
    }
}

You can find the available options here.

Save/Update Subscriptions

To save or update a subscription use the updatePushSubscription($endpoint, $key = null, $token = null, $contentEncoding = null) method on your user:

$user = \App\User::find(1);

$user->updatePushSubscription($endpoint, $key, $token, $contentEncoding);

The $key and $token are optional and are used to encrypt your notifications. Only encrypted notifications can have a payload.

Delete Subscriptions

To delete a subscription use the deletePushSubscription($endpoint) method on your user:

$user = \App\User::find(1);

$user->deletePushSubscription($endpoint);

Demo

For a complete implementation with a Service Worker check this demo.

Browser Compatibility

See the Push API browser compatibility.

Changelog

Please see CHANGELOG for more information about what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].