You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with this library for the first time (am also new to c++) and am running into an issue where the recommended code for usage will not send a toast notification, but including a second line of
WinToast::instance()->showToast(templ, handler)
causes 2 toast notifications to fire. Trying to understand what the root cause of this is so that I can resolve the issue I am experiencing here...
Code I have been using and experiencing the issue with is below and my compiler is set for c++20:
int main() {
if (!WinToast::isCompatible())
{
std::wcout << L"Error, your system in not supported!" << std::endl;
}
WinToast::instance()->setAppName(L"WinToastExample");
const auto aumi = WinToast::configureAUMI(L"mohabouje", L"wintoast", L"wintoastexample", L"20161006");
WinToast::instance()->setAppUserModelId(aumi);
if (!WinToast::instance()->initialize())
{
std::wcout << L"Error, could not initialize the lib!" << std::endl;
}
CustomHandler* handler = new CustomHandler;
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::Text02);
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
WinToast::instance()->showToast(templ, handler) // when this line is commented out, 0 toast notifications fire when compiled exe is run, when this line is included, 2 toast notifications fire when compiled exe is run
if (!WinToast::instance()->showToast(templ, handler))
{
std::wcout << L"Error: Could not launch your toast notification!" << std::endl;
}
}
definition of customHandler for reference (copy/paste from WinToast/example/qt-gui-example/WinToastExample/mainwindow.cpp):
class CustomHandler : public IWinToastHandler {
public:
void toastActivated() const {
std::wcout << L"The user clicked in this toast" << std::endl;
}
void toastActivated(int actionIndex) const {
std::wcout << L"The user clicked on button #" << actionIndex << L" in this toast" << std::endl;
}
void toastFailed() const {
std::wcout << L"Error showing current toast" << std::endl;
}
void toastDismissed(WinToastDismissalReason state) const {
switch (state) {
case UserCanceled:
std::wcout << L"The user dismissed this toast" << std::endl;
break;
case ApplicationHidden:
std::wcout << L"The application hid the toast using ToastNotifier.hide()" << std::endl;
break;
case TimedOut:
std::wcout << L"The toast has timed out" << std::endl;
break;
default:
std::wcout << L"Toast not activated" << std::endl;
break;
}
}
};
Any help that anyone can offer is greatly appreciated.
The text was updated successfully, but these errors were encountered:
I am working with this library for the first time (am also new to c++) and am running into an issue where the recommended code for usage will not send a toast notification, but including a second line of
WinToast::instance()->showToast(templ, handler)
causes 2 toast notifications to fire. Trying to understand what the root cause of this is so that I can resolve the issue I am experiencing here...
Code I have been using and experiencing the issue with is below and my compiler is set for c++20:
definition of customHandler for reference (copy/paste from WinToast/example/qt-gui-example/WinToastExample/mainwindow.cpp):
Any help that anyone can offer is greatly appreciated.
The text was updated successfully, but these errors were encountered: