diff --git a/src/controller.cpp b/src/controller.cpp index 4e031c941..b2449bfda 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -381,10 +381,18 @@ void Controller::listenForNotifications() #ifdef HAVE_KUNIFIEDPUSH auto connector = new KUnifiedPush::Connector(QStringLiteral("org.kde.neochat")); - connect(connector, &KUnifiedPush::Connector::messageReceived, [](const QByteArray &data) { + auto timer = new QTimer(); + connect(timer, &QTimer::timeout, qGuiApp, &QGuiApplication::quit); + + connect(connector, &KUnifiedPush::Connector::messageReceived, [timer](const QByteArray &data) { NotificationsManager::instance().postPushNotification(data); + timer->stop(); }); + // Wait five seconds to see if we received any messages or this happened to be an erroneous activation. + // Otherwise, messageReceived is never activated, and this daemon could stick around forever. + timer->start(5000); + connector->registerClient(i18n("Receiving push notifications")); #endif }