Api package to push notifications using realtime pusher node.js application with socket.io
Real-time push notification package for laravel, (*1)
Please checkout the following library before using it - instant-notify, (*2)
composer require tamizh/realtime-push
or add the following line in composer.json line, (*3)
"tamizh/realtime-push" : "dev-master" and run composer update
, (*4)
Add the service provider to your config/app.php file:, (*5)
'providers' => array( //... Realtime\Push\RealtimePusherProvider::class, ),
Add the facade to your config/app.php file:, (*6)
'facades' => array( //... 'Push' => Realtime\Push\Facades\RealtimePusher::class, ),
Publish config file using php artisan vendor:publish
Modifiy the config/realtime-pusher.php. That's all set for working with functions, (*7)
And a js file will be added in public/js/notification.js. include it in your layout or pages that you are need the push notification, (*8)
var notification = new Notification(<user secret>, <url>); notification.login(); notification.socket.on('notification',function(data){ // do the stuff you want with data })
As of now the text and image variables available in the server, soon it will be increased. Use text as json and parsse it in browser side javascript to have many variables., (*9)
1.createApp - to create app in notification server, (*10)
Push::createApp('test')
it will return a secert_id with success response. store or add it to the config file for creating users for this app, (*11)
2.createUser - to create User in notification server, (*12)
Push::createUser('name', 'password')
it will return the user secret with success message. store it in your database for sending notification to this user, (*13)
3.notify - to create and send it to the respective user, (*14)
Push::notify($user_secret, $text, $image)
You can find my laravel demo application here , (*15)