Saku-Overclock

Форк
0
/
AppNotificationActivationHandler.cs 
48 строк · 2.0 Кб
1
using Microsoft.UI.Dispatching;
2
using Microsoft.UI.Xaml;
3
using Microsoft.Windows.AppLifecycle;
4
using Saku_Overclock.Contracts.Services;
5

6
namespace Saku_Overclock.Activation;
7

8
public class AppNotificationActivationHandler : ActivationHandler<LaunchActivatedEventArgs>
9
{
10
    private readonly INavigationService _navigationService;
11
    private readonly IAppNotificationService _notificationService;
12

13
    public AppNotificationActivationHandler(INavigationService navigationService, IAppNotificationService notificationService)
14
    {
15
        _navigationService = navigationService;
16
        _notificationService = notificationService;
17
    }
18

19
    protected override bool CanHandleInternal(LaunchActivatedEventArgs args)
20
    {
21
        return AppInstance.GetCurrent().GetActivatedEventArgs()?.Kind == ExtendedActivationKind.AppNotification;
22
    }
23

24
    protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args)
25
    {
26
        // TODO: Handle notification activations.
27

28
        //// // Access the AppNotificationActivatedEventArgs.
29
        //// var activatedEventArgs = (AppNotificationActivatedEventArgs)AppInstance.GetCurrent().GetActivatedEventArgs().Data;
30

31
        //// // Navigate to a specific page based on the notification arguments.
32
        //// if (_notificationService.ParseArguments(activatedEventArgs.Argument)["action"] == "Settings")
33
        //// {
34
        ////     // Queue navigation with low priority to allow the UI to initialize.
35
        ////     App.MainWindow.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
36
        ////     {
37
        ////         _navigationService.NavigateTo(typeof(SettingsViewModel).FullName!);
38
        ////     });
39
        //// }
40

41
        App.MainWindow.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
42
        {
43
            App.MainWindow.ShowMessageDialogAsync("TODO: Handle notification activations.", "Notification Activation");
44
        });
45

46
        await Task.CompletedTask;
47
    }
48
}
49

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.