PHP code example of nineinchnick / yii-nfy
1. Go to this page and download the library: Download nineinchnick/yii-nfy library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nineinchnick / yii-nfy example snippets
$this->widget('nfy.extensions.webNotifications.WebNotifications', array(
'url'=>'ws://ws.pusherapp.com:80/app/XXXclient=javascript&protocol=6',
'method'=>WebNotifications::METHOD_PUSH,
'websocket'=>array(
'onopen'=>'js:function(socket){return function(e) {
socket.send(JSON.stringify({
"event": "pusher:subscribe",
"data": {"channel": "test_channel"}
}));
};}',
'onmessage'=>'js:function(_socket){return function(e) {
var message = JSON.parse(e.data);
var data = JSON.parse(message.data);
if (typeof data.title != "undefined" && typeof data.body != "undefined") {
notificationsPoller.addMessage(data);
notificationsPoller.display();
}
};}',
),
));