-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
65 changed files
with
528 additions
and
366 deletions.
There are no files selected for viewing
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
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
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
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
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
4 changes: 4 additions & 0 deletions
4
src/Templates/Boilerplate/Bit.Boilerplate/settings.VisualStudio.json
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,4 @@ | ||
/* Visual Studio Settings File */ | ||
{ | ||
"debugging.general.disableJITOptimization": true | ||
} |
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
public interface IAuthTokenProvider | ||
{ | ||
Task<string?> GetAccessTokenAsync(); | ||
Task<string?> GetAccessToken(); | ||
} |
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
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
36 changes: 14 additions & 22 deletions
36
...it.Boilerplate/src/Client/Boilerplate.Client.Core/Services/PushNotificationServiceBase.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 |
---|---|---|
@@ -1,45 +1,37 @@ | ||
using Boilerplate.Shared.Controllers; | ||
using Boilerplate.Shared.Controllers.PushNotification; | ||
using Boilerplate.Shared.Dtos.PushNotification; | ||
|
||
namespace Boilerplate.Client.Core.Services; | ||
|
||
public abstract partial class PushNotificationServiceBase : IPushNotificationService | ||
{ | ||
[AutoInject] protected INotificationHubController pushNotificationController = default!; | ||
[AutoInject] protected IStorageService storageService = default!; | ||
[AutoInject] protected IPushNotificationController pushNotificationController = default!; | ||
[AutoInject] protected IConfiguration configuration = default!; | ||
[AutoInject] protected IJSRuntime jsRuntime = default!; | ||
[AutoInject] protected JsonSerializerOptions jsonSerializerOptions = default!; | ||
|
||
public virtual string Token { get; set; } | ||
public virtual bool NotificationsSupported => false; | ||
public virtual string GetDeviceId() => throw new NotImplementedException(); | ||
public virtual DeviceInstallationDto GetDeviceInstallation() => throw new NotImplementedException(); | ||
|
||
public async Task RegisterDeviceAsync(CancellationToken cancellationToken) | ||
public virtual async Task<DeviceInstallationDto> GetDeviceInstallation() | ||
{ | ||
if (NotificationsSupported is false) | ||
return; | ||
|
||
var deviceInstallation = GetDeviceInstallation(); | ||
|
||
await pushNotificationController.CreateOrUpdateInstallation(deviceInstallation, cancellationToken); | ||
|
||
await storageService.SetItem("device_token", deviceInstallation.PushChannel); | ||
return await jsRuntime.GetDeviceInstallation(configuration.GetRequiredValue<string>("AdsPush:Primary:Vapid:PublicKey")); | ||
} | ||
|
||
public async Task DeregisterDeviceAsync(CancellationToken cancellationToken) | ||
public async Task RegisterDevice(CancellationToken cancellationToken) | ||
{ | ||
if (NotificationsSupported is false) | ||
return; | ||
|
||
var cachedToken = await storageService.GetItem("device_token"); | ||
var deviceInstallation = await GetDeviceInstallation(); | ||
|
||
if (cachedToken == null) | ||
if (deviceInstallation is null) | ||
return; | ||
|
||
var deviceId = GetDeviceId() ?? throw new InvalidOperationException("Unable to resolve an ID for the device."); | ||
|
||
await pushNotificationController.DeleteInstallation(deviceId, cancellationToken); | ||
await pushNotificationController.RegisterDevice(deviceInstallation, cancellationToken); | ||
} | ||
|
||
await storageService.RemoveItem("device_token"); | ||
public async Task DeregisterDevice(string deviceInstallationId, CancellationToken cancellationToken) | ||
{ | ||
await pushNotificationController.DeregisterDevice(deviceInstallationId, cancellationToken); | ||
} | ||
} |
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
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
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
Oops, something went wrong.