Hi thogether. I want to create a new plugin which will be execute only one time, directly after the login and it should pass data to a client javascript to show a html5 notification. I have added here some example code. I didnt get errors. I can see at the server that the string "test if hookis executed" is added to the error.log file. So this part is executed. In the browser console i see "initiated", but i never see the data from the server with the line "data from plugin: somedata", which i expected. Do i miss something? the callback show_notifications seems to be never triggered...
plugin.php
class myplugin extends rcube_plugin
{
public function init() {
$rcmail = rcmail::get_instance();
$this->include_script('client.js');
$this->add_hook('login_after', array($this, 'get_data'));
}
function get_data() {
$rcmail = rcmail::get_instance();
$data = "somedata"; error_log("test if hookis executed"); $rcmail->output->command('plugin.showNotification', $data);
}}
client.jsfunction get_notifications(data) {
console.log("data from plugin: "+data);
}
function test() {
console.log("initiated");
}
if (window.rcmail)
{
rcmail.addEventListener('plugin.showNotification', show_notifications);
rcmail.addEventListener('init', test);
}