N
N
newbieman2015-04-18 01:52:09
Yii
newbieman, 2015-04-18 01:52:09

How to send a notification using session->setFlash to another user?

I use alert from v-kartik. Everything works, but ...
It is necessary that when sending a message, a notification is received not by the sender, but by the recipient.
in controller:

Yii::$app->getSession(тут должен быть ид юзера?)->setFlash('message, [
 ]);
 return $this->redirect(['view', 'id' => $model->id]);
} else {
 return $this->render('create', [
             'model' => $model,
 ]);
}

in view:
<?php foreach (Yii::$app->session->getFlash(ид юзера) as $message):; ?>

<?php
echo Growl::widget([
    'type' => Growl::TYPE_GROWL,
    'title' => 'Roar!',
    'icon' => '/images/icon.png',
    'body' => 'This is a default growling alert you requested for.',
    'showSeparator' => false,
    'delay' => 6000,
    'pluginOptions' => [
        'icon_type'=>'image',
        'placement' => [
            'from' => 'top',
            'align' => 'right',
        ],
        'template' => [
            'icon_type' => 'image'
        ]
    ]
]);
?>
        <?php endforeach; ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-04-18
Protko @Fesor

using session->setFlash to another user?

No way, session->setFlash uses the session of the current user, and no one else. In your case, you need to enter some kind of push server and send notifications to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question