Notifications
Notifications pop up quick notifications.
Getting Started
@inject NotificationService NotificationService
@inject SoundService SoundService
<button class="btn btn-primary" @onclick="AddNotification">Add Notification!</button>
<button class="btn btn-primary" @onclick="AddNotificationWithSound">Add Notification With Sound!</button>
@code {
public async Task AddNotification()
{
var options = new NotificationOptions()
{
Body = "This is an example notification body",
Icon = "images/graviton-icon.png",
Image = "images/futuristic-city.png"
};
var notification = new Notification("Hello notifications", options);
await NotificationService.Push(notification);
}
public async Task AddNotificationWithSound()
{
var options = new NotificationOptions()
{
Body = "This is an example notification body",
Icon = "images/graviton-icon.png",
Image = "images/futuristic-city.png",
Silent = true,
Vibrate = null
};
var notification = new Notification("Hello notifications", options);
if (await NotificationService.Push(notification))
{
await SoundService.PlaySound("_content/Graviton.Components/sounds/pop.mp3");
};
}
}