alymosul/laravel-exponent-push-notifications
Composer 安装命令:
composer require alymosul/laravel-exponent-push-notifications
包简介
Exponent push notifications driver for laravel
README 文档
README
Contents
- Installation
- Usage - Available Message methods
- Changelog
- Testing
- Security
- Contributing
- Credits
- License
Installation
You can install the package via composer:
composer require alymosul/laravel-exponent-push-notifications
If you are using Laravel 5.5 or higher this package will automatically register itself using Package Discovery. For older versions of Laravel you must install the service provider manually:
// config/app.php 'providers' => [ ... NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider::class, ],
Before publish exponent notification migration you must add in .env file:
EXPONENT_PUSH_NOTIFICATION_INTERESTS_STORAGE_DRIVER=database
You can publish the migration with:
php artisan vendor:publish --provider="NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider" --tag="migrations"
After publishing the migration you can create the exponent_push_notification_interests table by running the migrations:
php artisan migrate
You can optionally publish the config file with:
php artisan vendor:publish --provider="NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider" --tag="config"
This is the contents of the published config file:
return [ 'interests' => [ /* * Supported: "file", "database" */ 'driver' => env('EXPONENT_PUSH_NOTIFICATION_INTERESTS_STORAGE_DRIVER', 'file'), 'database' => [ 'events' => [], 'table_name' => 'exponent_push_notification_interests', ], ] ];
Usage
use NotificationChannels\ExpoPushNotifications\ExpoChannel; use NotificationChannels\ExpoPushNotifications\ExpoMessage; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [ExpoChannel::class]; } public function toExpoPush($notifiable) { return ExpoMessage::create() ->badge(1) ->enableSound() ->title("Congratulations!") ->body("Your {$notifiable->service} account was approved!"); } }
Available Message methods
A list of all available options
title(''): Accepts a string value for the title.body(''): Accepts a string value for the body.enableSound(): Enables the notification sound.disableSound(): Mutes the notification sound.badge(1): Accepts an integer value for the badge.ttl(60): Accepts an integer value for the time to live.setJsonData(''): Accepts a json string or an array for additional.channelID(''): Accepts a string to set the channelId of the notification for Android devices.priority('default'): Accepts a string to set the priority of the notification, must be one of [default, normal, high].
Managing Recipients
This package registers two endpoints that handle the subscription of recipients, the endpoints are defined in src/Http/routes.php file, used by ExpoController and all loaded through the package service provider.
Routing a message
By default the exponent "interest" messages will be sent to will be defined using the {notifiable}.{id} convention, for example App.User.1, however you can change this behaviour by including a routeNotificationForExpoPushNotifications() in the notifiable class method that returns the interest name.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email alymosul@gmail.com 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.
alymosul/laravel-exponent-push-notifications 适用场景与选型建议
alymosul/laravel-exponent-push-notifications 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 751.96k 次下载、GitHub Stars 达 142, 最近一次更新时间为 2017 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 alymosul/laravel-exponent-push-notifications 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alymosul/laravel-exponent-push-notifications 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 751.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 142
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-08