@@ -27,6 +27,7 @@ public static class ToastNotificationManagerCompat
27
27
#if WIN32
28
28
private const string TOAST_ACTIVATED_LAUNCH_ARG = "-ToastActivated" ;
29
29
private const string REG_HAS_SENT_NOTIFICATION = "HasSentNotification" ;
30
+ private const string REG_HAS_7_0_1_FIX = "Has7.0.1Fix" ;
30
31
internal const string DEFAULT_GROUP = "toolkitGroupNull" ;
31
32
32
33
private const int CLASS_E_NOAGGREGATION = - 2147221232 ;
@@ -175,6 +176,22 @@ private static void Initialize()
175
176
176
177
// Additionally, we need to read whether they've sent a notification before
177
178
_hasSentNotification = rootKey . GetValue ( REG_HAS_SENT_NOTIFICATION ) != null ;
179
+
180
+ // And read if we've already applied the 7_0_1 fix
181
+ bool has7_0_1fix = rootKey . GetValue ( REG_HAS_7_0_1_FIX ) != null ;
182
+
183
+ // If it doesn't have the fix yet
184
+ if ( ! has7_0_1fix )
185
+ {
186
+ // If the AUMID changed
187
+ if ( win32AppInfo . Pre7_0_1Aumid != null )
188
+ {
189
+ // Uninstall the old AUMID
190
+ }
191
+
192
+ // Set that it has the fix so we don't try uninstalling again in the future
193
+ rootKey . SetValue ( REG_HAS_7_0_1_FIX , 1 ) ;
194
+ }
178
195
}
179
196
180
197
rootKey . SetValue ( "CustomActivator" , string . Format ( "{{{0}}}" , activatorType . GUID ) ) ;
@@ -183,7 +200,12 @@ private static void Initialize()
183
200
184
201
private static string GetRegistrySubKey ( )
185
202
{
186
- return @"Software\Classes\AppUserModelId\" + _win32Aumid ;
203
+ return GetRegistrySubKey ( _win32Aumid ) ;
204
+ }
205
+
206
+ private static string GetRegistrySubKey ( string win32Aumid )
207
+ {
208
+ return @"Software\Classes\AppUserModelId\" + win32Aumid ;
187
209
}
188
210
189
211
private static Type CreateActivatorType ( )
@@ -516,21 +538,71 @@ public static void Uninstall()
516
538
{
517
539
}
518
540
519
- if ( ! DesktopBridgeHelpers . HasIdentity ( ) && _win32Aumid != null )
541
+ try
520
542
{
521
- try
543
+ // Delete any of the app files
544
+ var appDataFolderPath = Win32AppInfo . GetAppDataFolderPath ( _win32Aumid ) ;
545
+ if ( Directory . Exists ( appDataFolderPath ) )
522
546
{
523
- // Delete any of the app files
524
- var appDataFolderPath = Win32AppInfo . GetAppDataFolderPath ( _win32Aumid ) ;
525
- if ( Directory . Exists ( appDataFolderPath ) )
547
+ Directory . Delete ( appDataFolderPath , recursive : true ) ;
548
+ }
549
+ }
550
+ catch
551
+ {
552
+ }
553
+ }
554
+
555
+ private static void CleanUpOldAumid ( string oldAumid )
556
+ {
557
+ try
558
+ {
559
+ // Remove all scheduled notifications (do this first before clearing current notifications)
560
+ var notifier = ToastNotificationManager . CreateToastNotifier ( oldAumid ) ;
561
+ foreach ( var scheduled in notifier . GetScheduledToastNotifications ( ) )
562
+ {
563
+ try
564
+ {
565
+ notifier . RemoveFromSchedule ( scheduled ) ;
566
+ }
567
+ catch
526
568
{
527
- Directory . Delete ( appDataFolderPath , recursive : true ) ;
528
569
}
529
570
}
530
- catch
571
+ }
572
+ catch
573
+ {
574
+ }
575
+
576
+ try
577
+ {
578
+ // Clear all current notifications
579
+ ToastNotificationManager . History . Clear ( oldAumid ) ;
580
+ }
581
+ catch
582
+ {
583
+ }
584
+
585
+ try
586
+ {
587
+ // Remove registry key
588
+ Registry . CurrentUser . DeleteSubKey ( GetRegistrySubKey ( oldAumid ) ) ;
589
+ }
590
+ catch
591
+ {
592
+ }
593
+
594
+ try
595
+ {
596
+ // Delete any of the app files
597
+ var appDataFolderPath = Win32AppInfo . GetAppDataFolderPath ( oldAumid ) ;
598
+ if ( Directory . Exists ( appDataFolderPath ) )
531
599
{
600
+ Directory . Delete ( appDataFolderPath , recursive : true ) ;
532
601
}
533
602
}
603
+ catch
604
+ {
605
+ }
534
606
}
535
607
#endif
536
608
0 commit comments