xcoorp/laravel-webpush-notifications
Composer 安装命令:
composer require xcoorp/laravel-webpush-notifications
包简介
Web Push Notifications channel for Laravel.
README 文档
README
WebPush - Laravel Notification Channel
This package makes it easy to send notifications using Web Push API
class InvoicePaidNotification extends Notification { // Trigger a specific notification event public function toWebPush($notifiable) { return (new WebPushMessage) ->title('Approved!') ->body('Your account was approved!') ->action('View account', 'view_account') ->options(['TTL' => 1000]); } }
Contents
Installation
The Web Push notification channel can be installed easily via Composer:
composer require xcoorp/laravel-webpush-notifications
Publishing Configuration and Migrations
After installing the package, you can publish the configuration file and migrations by running the following command:
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider"
After publishing the migrations you should migrate your database:
php artisan migrate
After publishing the configuration file, you should configure the vapid keys in your .env file:
VAPID_PUBLIC_KEY=your-public-key VAPID_PRIVATE_KEY=your-private-key VAPID_SUBJECT=your-email or url
You can generate the vapid keys using the following command:
php artisan webpush-notifications:vapid
Configuration
The config/webpush-notifications.php configuration file allows you to configure the default Web Push options for your application.
You can define custom Models to use, and the vapid keys to use for the Web Push API.
If you define a custom UsereWebPushSubscription model you need to make sure it extends the UsereWebPushSubscription model shipped with this package.
Usage
In order to send a notification via the WebPush channel, you'll need to specify the channel in the via() method of your notification:
use NotificationChannels\WebPush\WebPushChannel; public function via($notifiable) { return [ WebPushChannel::class ] }
API Overview
WebPush Message
Namespace: NotificationChannels\WebPush\WebPushMessage
The WebPushMessage class encompasses an entire message that will be sent to the Web Push API.
title(string $title)Set thetitleof the messageaction(string $title, string $action, ?string $icon = null))Set theactionof the messagebadge(string $badge)Set the url to thebadgeimage of the messagebody(string $body)Set thebodyof the messagedir(string $dir)Set the text-directiondirof the messageicon(string $icon)Set the url to theiconof the messageimage(string $image)Set the url to theimageof the messagelang(string $lang)Set the Languagelangof the messagerenotify(bool $renotify)specifies whether the user should be notified after a new notification replaces an old onerequireInteraction(bool $requireInteraction)specifies whether the notification requires interactiontag(string $value)Set thetagof the messagevibrate(array $vibrate)Set the vibration patternvibrateof the messagedata(mixed $value)Set thedataof the messageoptions(array $options)Set theoptionsof the message (See here for more information)toArray()Returns the data that will be sent to the WebPush API as an array
Code of Conduct
In order to ensure that the community is welcoming to all, please review and abide by the Code of Conduct.
Security Vulnerabilities
Please review the security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.
xcoorp/laravel-webpush-notifications 适用场景与选型建议
xcoorp/laravel-webpush-notifications 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.45k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notifications」 「laravel」 「WebPush」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xcoorp/laravel-webpush-notifications 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xcoorp/laravel-webpush-notifications 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xcoorp/laravel-webpush-notifications 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
OneSignal REST API Wrapper For Laravel/Lumen
A Laravel Nova package that adds a notification feed in your Nova app.
Laravel OneSignal Notification
Web-Push framework for PHP
OneSignal Push Wrapper Laravel
Captures outgoing SMS notifications
统计信息
- 总下载量: 1.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-04