@@ -201,13 +201,28 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */,
201201}
202202
203203// DesktopToastFailedEventHandler
204- IFACEMETHODIMP ToastEventHandler::Invoke (_In_ IToastNotification* /* sender */ , _In_ IToastFailedEventArgs* /* e */ )
204+ IFACEMETHODIMP ToastEventHandler::Invoke (_In_ IToastNotification* /* sender */ , _In_ IToastFailedEventArgs* e )
205205{
206- BOOL succeeded = nw::NotificationManager::getSingleton ()->DesktopNotificationPostError (_render_process_id, _render_frame_id, _notification_id, L" The toast encountered an error." );
206+ HRESULT errCode;
207+ e->get_ErrorCode (&errCode);
208+ nw::NotificationManagerToastWin* nmtw = static_cast <nw::NotificationManagerToastWin*>(nw::NotificationManager::getSingleton ());
209+ std::wstringstream errMsg; errMsg << L" The toast encountered an error code (0x" << std::hex << errCode <<" )." ;
210+ const bool fallBack = errCode == 0x80070490 ;
211+ if (fallBack)
212+ errMsg << " Fallback to balloon notification!" ;
213+
214+ BOOL succeeded = nmtw->DesktopNotificationPostError (_render_process_id, _render_frame_id, _notification_id, errMsg.str ().c_str ());
215+ nmtw->notification_map_ .erase (_notification_id);
216+
217+ if (fallBack) {
218+ NotificationManagerToastWin::ForceDisable = true ;
219+ delete nmtw;
220+ }
207221 return succeeded ? S_OK : E_FAIL;
208222}
209223
210224// ============= NotificationManagerToastWin Implementation =============
225+ bool NotificationManagerToastWin::ForceDisable = false ;
211226
212227HRESULT NotificationManagerToastWin::SetNodeValueString (_In_ HSTRING inputString, _In_ IXmlNode *node, _In_ IXmlDocument *xml)
213228{
@@ -357,7 +372,7 @@ HRESULT NotificationManagerToastWin::CreateToast(_In_ IToastNotificationManagerS
357372
358373bool NotificationManagerToastWin::IsSupported () {
359374 static char cachedRes = -1 ;
360-
375+ if (ForceDisable) return false ;
361376 if (cachedRes > -1 ) return cachedRes;
362377 cachedRes = 0 ;
363378
0 commit comments