elnooronline/onesignal
Composer 安装命令:
composer require elnooronline/onesignal
包简介
OneSignal Notifications driver
README 文档
README
This package makes it easy to send OneSignal notifications with Laravel 5.3.
Contents
Installation
You can install the package via composer:
composer require laravel-notification-channels/onesignal
You must install the service provider:
// config/app.php 'providers' => [ ... NotificationChannels\OneSignal\OneSignalServiceProvider::class, ],
Setting up your OneSignal account
Add your OneSignal App ID and REST API Key to your config/services.php:
// config/services.php ... 'onesignal' => [ 'app_id' => env('ONESIGNAL_APP_ID'), 'rest_api_key' => env('ONESIGNAL_REST_API_KEY') ], ...
Usage
Now you can use the channel in your via() method inside the notification:
use NotificationChannels\OneSignal\OneSignalChannel; use NotificationChannels\OneSignal\OneSignalMessage; use NotificationChannels\OneSignal\OneSignalWebButton; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [OneSignalChannel::class]; } public function toOneSignal($notifiable) { return OneSignalMessage::create() ->subject("Your {$notifiable->service} account was approved!") ->body("Click here to see details.") ->url('http://onesignal.com') ->webButton( OneSignalWebButton::create('link-1') ->text('Click here') ->icon('https://upload.wikimedia.org/wikipedia/commons/4/4f/Laravel_logo.png') ->url('http://laravel.com') ); } }
In order to let your Notification know which OneSignal user(s) you are targeting, add the routeNotificationForOneSignal method to your Notifiable model.
You can either return a single player-id, or if you want to notify multiple player IDs just return an array containing all IDs.
public function routeNotificationForOneSignal() { return 'ONE_SIGNAL_PLAYER_ID'; }
All available methods
subject(''): Accepts a string value for the title.body(''): Accepts a string value for the notification body.icon(''): Accepts an url for the icon.url(''): Accepts an url for the notification click event.webButton(OneSignalWebButton $button): Allows you to add action buttons to the notification (Chrome 48+ (web push) only).button(OneSignalButton $button): Allows you to add buttons to the notification (Supported by iOS 8.0 and Android 4.1+ devices. Icon only works for Android).setData($key, $value): Allows you to set additional data for the message payload. For more information check the OneSignal documentation.
Button usage
OneSignalMessage::create() ->button( OneSignalButton::create('id') ->text('button text') ->icon('button icon') );
WebButton usage
OneSignalMessage::create() ->webButton( OneSignalWebButton::create('id') ->text('button text') ->icon('button icon') ->url('button url') );
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email m.pociot@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.
elnooronline/onesignal 适用场景与选型建议
elnooronline/onesignal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 317 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 elnooronline/onesignal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elnooronline/onesignal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 317
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-13