tamizh / realtime-push
使用实时推送器 Node.js 应用程序和 socket.io 推送通知的 API 包
1.0.0
2016-10-16 03:43 UTC
This package is not auto-updated.
Last update: 2024-09-18 20:54:21 UTC
README
为 Laravel 提供实时推送通知包
请在使用之前检查以下库 - instant-notify
安装
composer require tamizh/realtime-push
在 composer.json 文件中添加以下行
"tamizh/realtime-push" : "dev-master" 并运行 composer update
将服务提供者添加到 config/app.php 文件中
'providers' => array(
//...
Realtime\Push\RealtimePusherProvider::class,
),
将外观添加到 config/app.php 文件中
'facades' => array(
//...
'Push' => Realtime\Push\Facades\RealtimePusher::class,
),
使用 php artisan vendor:publish
发布配置文件。修改 config/realtime-pusher.php。这样就可以使用函数工作了
并且会在 public/js/notification.js 中添加一个 js 文件。将其包含到您需要推送通知的布局或页面中
var notification = new Notification(<user secret>, <url>);
notification.login();
notification.socket.on('notification',function(data){
// do the stuff you want with data
})
目前服务器上提供了文本和图像变量,很快将增加更多。使用文本作为 json 并在浏览器端 JavaScript 中解析它以拥有更多变量。
#函数
1.createApp - 在通知服务器中创建应用
Push::createApp('test')
它将返回一个 secret_id,并成功响应。将其存储或添加到配置文件中,用于为该应用创建用户
2.createUser - 在通知服务器中创建用户
Push::createUser('name', 'password')
它将返回用户 secret 和成功消息。将其存储在您的数据库中,以便向该用户发送通知
3.notify - 创建并发送到相应的用户
Push::notify($user_secret, $text, $image)
#示例
您可以在这里找到我的 Laravel 示例应用程序