bariew / yii2-pusher
yii2 web push for pusher.com
Installs: 234
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Type:helpers
Requires
- pusher/pusher-php-server: ^2.2
- yiisoft/yii2: >=2.0.7
This package is auto-updated.
Last update: 2024-12-16 15:44:13 UTC
README
INSTALL
php composer.phar require bariew/yii2-pusher
USAGE
1. Add a new component into yor config file:
'components' => [
'webpusher' => [
'class' => 'bariew\yii2Pusher\Component',
'app_id' => '***', // get your credentials on pusher.com
'key' => '***',
'secret' => '***',
]
]
2. Include a widget into your view file e.g. "main.php":
<?= \bariew\yii2Pusher\Widget::widget(['events' => [
'notification' => new \yii\web\JsExpression("function(data){console.log(data);}")
]]) ?>
3. Now you can send a notification to any user or an array of users:
Yii::$app->webpusher->userPush("hello user", [Yii::$app->user->id]);