-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/HyPlayer.App/Interfaces/Services/IAppNotificationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Specialized; | ||
|
||
namespace HyPlayer.Interfaces.Services; | ||
|
||
public interface IAppNotificationService | ||
{ | ||
void Initialize(); | ||
|
||
bool Show(string payload); | ||
|
||
NameValueCollection ParseArguments(string arguments); | ||
|
||
void Unregister(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Specialized; | ||
using System.Web; | ||
|
||
using HyPlayer.Interfaces.Services; | ||
|
||
using Microsoft.Windows.AppNotifications; | ||
|
||
namespace HyPlayer.Services; | ||
|
||
public class AppNotificationService : IAppNotificationService | ||
{ | ||
public AppNotificationService() | ||
{ | ||
} | ||
|
||
~AppNotificationService() | ||
{ | ||
Unregister(); | ||
} | ||
|
||
public void Initialize() | ||
{ | ||
AppNotificationManager.Default.NotificationInvoked += OnNotificationInvoked; | ||
|
||
AppNotificationManager.Default.Register(); | ||
} | ||
|
||
public void OnNotificationInvoked(AppNotificationManager sender, AppNotificationActivatedEventArgs args) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool Show(string payload) | ||
{ | ||
var appNotification = new AppNotification(payload); | ||
|
||
AppNotificationManager.Default.Show(appNotification); | ||
|
||
return appNotification.Id != 0; | ||
} | ||
|
||
public NameValueCollection ParseArguments(string arguments) | ||
{ | ||
return HttpUtility.ParseQueryString(arguments); | ||
} | ||
|
||
public void Unregister() | ||
{ | ||
AppNotificationManager.Default.Unregister(); | ||
} | ||
} |