Adding contact details for loaded mails and fixing background notification actions.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using Windows.ApplicationModel.Background;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
@@ -7,6 +10,7 @@ namespace Wino.Core.UWP.Services
|
||||
public class BackgroundTaskService : IBackgroundTaskService
|
||||
{
|
||||
private const string IsBackgroundTasksUnregisteredKey = nameof(IsBackgroundTasksUnregisteredKey);
|
||||
public const string ToastNotificationActivationHandlerTaskName = "ToastNotificationActivationHandlerTask";
|
||||
|
||||
private readonly IConfigurationService _configurationService;
|
||||
|
||||
@@ -17,7 +21,7 @@ namespace Wino.Core.UWP.Services
|
||||
|
||||
public void UnregisterAllBackgroundTask()
|
||||
{
|
||||
if (!_configurationService.Get(IsBackgroundTasksUnregisteredKey, false))
|
||||
if (_configurationService.Get(IsBackgroundTasksUnregisteredKey, false))
|
||||
{
|
||||
foreach (var task in BackgroundTaskRegistration.AllTasks)
|
||||
{
|
||||
@@ -28,5 +32,32 @@ namespace Wino.Core.UWP.Services
|
||||
_configurationService.Set(IsBackgroundTasksUnregisteredKey, true);
|
||||
}
|
||||
}
|
||||
|
||||
public Task RegisterBackgroundTasksAsync()
|
||||
{
|
||||
return RegisterToastNotificationHandlerBackgroundTaskAsync();
|
||||
}
|
||||
|
||||
public async Task RegisterToastNotificationHandlerBackgroundTaskAsync()
|
||||
{
|
||||
// If background task is already registered, do nothing.
|
||||
if (BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(ToastNotificationActivationHandlerTaskName)))
|
||||
return;
|
||||
|
||||
// Otherwise request access
|
||||
BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();
|
||||
|
||||
// Create the background task
|
||||
BackgroundTaskBuilder builder = new BackgroundTaskBuilder()
|
||||
{
|
||||
Name = ToastNotificationActivationHandlerTaskName
|
||||
};
|
||||
|
||||
// Assign the toast action trigger
|
||||
builder.SetTrigger(new ToastNotificationActionTrigger());
|
||||
|
||||
// And register the task
|
||||
BackgroundTaskRegistration registration = builder.Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user