diff --git a/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor b/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor index db1b7d9a2d..590df055df 100644 --- a/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor +++ b/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor @@ -22,8 +22,8 @@ @@inject Bit.Butil.Notification notification @@code { - notification.IsSupported(); - notification.Show("title", new() { Body = "this is body." }); + await notification.IsSupported(); + await notification.Show("title", new() { Body = "this is body." }); } @@ -43,6 +43,8 @@ +
+ Notification supported? [@isNotificationSupported]
IsSupported
@@ -51,68 +53,69 @@

- Show:
- Requests a native notification to show to the user. - (MDN). + GetPermission:
+ Gets the current permission of the Notification API. + (MDN).

- @showExampleCode + @getPermissionExampleCode
- Show + Current permission state: [@permissionResult] +
+ GetPermission


- GetPermission:
- Gets the current permission of the Notification API. - (MDN). + RequestPermission:
+ Requests permission from the user for the current origin to display notifications. + (MDN).

- @getPermissionExampleCode + @requestPermissionExampleCode
- Current permission state: [@permissionResult] + Request permission result: [@requestPermissionResult]
- GetPermission + RequestPermission


- RequestPermission:
- Requests permission from the user for the current origin to display notifications. - (MDN). + Show:
+ Requests a native notification to show to the user. + (MDN).

- @requestPermissionExampleCode + @showExampleCode
- Request permission result: [@requestPermissionResult] -
- RequestPermission + Show
+

diff --git a/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor.cs b/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor.cs index 533b5df7e9..7eed395f3b 100644 --- a/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor.cs +++ b/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Butil/Butil08NotificationPage.razor.cs @@ -4,72 +4,85 @@ namespace Bit.Websites.Platform.Client.Pages.Butil; public partial class Butil08NotificationPage { + private bool? isNotificationSupported; private async Task CheckIsSupported() { - var isNotificationSupported = await notification.IsSupported(); - } - - private async Task ShowNotification() - { - await notification.Show("title", new() { Body = "this is body." }); + isNotificationSupported = await notification.IsSupported(); } private NotificationPermission? permissionResult = null; - private async Task GetCurrentPermissionState() { permissionResult = await notification.GetPermission(); } private NotificationPermission? requestPermissionResult = null; - private async Task RequestPermission() { requestPermissionResult = await notification.RequestPermission(); } + private async Task ShowNotification() + { + await notification.Show("title", new() { Body = "this is body." }); + } + private string isSupportedExampleCode = @"@inject Bit.Butil.Notification notification +Notification supported? [@isNotificationSupported] + IsSupported @code { + private bool? isNotificationSupported; + private async Task CheckIsSupported() { - var isNotificationSupported = await notification.IsSupported(); + isNotificationSupported = await notification.IsSupported(); } }"; - private string showExampleCode = + private string getPermissionExampleCode = @"@inject Bit.Butil.Notification notification -Show +Current permission state: [@permissionResult] + +GetPermission @code { - private async Task ShowNotification() + private NotificationPermission? permissionResult = null; + + private async Task GetCurrentPermissionState() { - await notification.Show(""title"", new() { Body = ""this is body."" }); + permissionResult = await notification.GetPermission(); } }"; - private string getPermissionExampleCode = -@"@inject Bit.Butil.Console console + private string requestPermissionExampleCode = +@"@inject Bit.Butil.Notification notification - +Request permission result: [@requestPermissionResult] - console.CountReset(value))"">CountReset +RequestPermission @code { - private string value = ""Test""; -}"; - private string requestPermissionExampleCode = -@"@inject Bit.Butil.Console console + private NotificationPermission? requestPermissionResult = null; - + private async Task RequestPermission() + { + requestPermissionResult = await notification.RequestPermission(); + } +}"; + private string showExampleCode = +@"@inject Bit.Butil.Notification notification - console.Debug(value))"">Debug +Show @code { - private string value = ""Test""; + private async Task ShowNotification() + { + await notification.Show(""title"", new() { Body = ""this is body."" }); + } }"; }