luisbahamonde/laravel-push-notification
Composer 安装命令:
composer require luisbahamonde/laravel-push-notification
包简介
Laravel package to send push notifications to mobile devices (apns, gcm)
关键字:
README 文档
README
Package to enable sending push notifications to devices
Installation
Update your composer.json file to include this package as a dependency
Laravel 6.x, 7.x
composer require luisbahamonde/laravel-push-notification
Laravel 5 & Lumen
"davibennun/laravel-push-notification": "dev-laravel5"
Laravel 4.*
"davibennun/laravel-push-notification": "dev-master"
Register the PushNotification service provider by adding it to the providers array.
'providers' => array( ... 'Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider' )
Alias the PushNotification facade by adding it to the aliases array in the app/config/app.php file.
'aliases' => array( ... 'PushNotification' => 'Davibennun\LaravelPushNotification\Facades\PushNotification' )
Configuration
Copy the config file into your project by running: (Lumen users skip this)
Laravel 5.x, 6.x, 7.x
php artisan vendor:publish --provider="Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider" --tag="config"
Laravel 4.*
php artisan config:publish davibennun/laravel-push-notification
This will generate a config file like this
array( 'appNameIOS'=>array( 'environment' => 'development', 'certificate' => '/path/to/certificate.pem', 'passPhrase' => 'password', 'service' => 'apns' ), 'appNameAndroid'=>array( 'environment' => 'production', 'apiKey' => 'yourAPIKey', 'service' => 'gcm' ) );
Where all first level keys corresponds to an service configuration, each service has its own properties, android for instance have apiKey and IOS uses certificate and passPhrase. You can set as many services configurations as you want, one for each app.
Dont forget to set service key to identify IOS 'service'=>'apns' and Android 'service'=>'gcm'
The certificate path must be an absolute path, so in the configuration file you can use these:
//Path to the 'app' folder
'certificate'=>app_path().'/myCert.pem'
Laravel functions are also available public_path() storage_path() base_path()
Usage
PushNotification::app('appNameIOS') ->to($deviceToken) ->send('Hello World, i`m a push message');
Where app argument appNameIOS refers to defined service in config file.
###Dynamic configuration and Lumen users You can set the app config array directly: (keep in mind the array schema)
//iOS app PushNotification::app(['environment' => 'development', 'certificate' => '/path/to/certificate.pem', 'passPhrase' => 'password', 'service' => 'apns']); //Android app PushNotification::app(['environment' => 'production', 'apiKey' => 'yourAPIKey', 'service' => 'gcm']);
To multiple devices and optioned message:
$devices = PushNotification::DeviceCollection(array( PushNotification::Device('token', array('badge' => 5)), PushNotification::Device('token1', array('badge' => 1)), PushNotification::Device('token2') )); $message = PushNotification::Message('Message Text',array( 'badge' => 1, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array( 'localized args', 'localized args', ), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array( 'we' => 'want', 'send to app' )) )); $collection = PushNotification::app('appNameIOS') ->to($devices) ->send($message); // get response for each device push foreach ($collection->pushManager as $push) { $response = $push->getAdapter()->getResponse(); } // access to adapter for advanced settings $push = PushNotification::app('appNameAndroid'); $push->adapter->setAdapterParameters(['sslverifypeer' => false]);
This package is wrapps Notification Package and adds some flavor to it.
Usage advice
This package should be used with Laravel Queues, so pushes dont blocks the user and are processed in the background, meaning a better flow.
luisbahamonde/laravel-push-notification 适用场景与选型建议
luisbahamonde/laravel-push-notification 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.08k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notification」 「laravel」 「push」 「gcm」 「apns」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 luisbahamonde/laravel-push-notification 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 luisbahamonde/laravel-push-notification 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 luisbahamonde/laravel-push-notification 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
Extensible library for building notifications and sending them via different delivery channels.
Simple javascript toast notifications
Send push notification to android|ios devices , support APNs, FCM
统计信息
- 总下载量: 2.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2021-02-10