Iniziata implementazione notifiche firebase
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Maui.Core.RestClient.IntegryApi.Dto;
|
||||
|
||||
public class RegisterDeviceDTO
|
||||
{
|
||||
[JsonPropertyName("userDeviceToken")]
|
||||
public WtbUserDeviceTokenDTO UserDeviceToken { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Maui.Core.RestClient.IntegryApi.Dto;
|
||||
|
||||
public class WtbUserDeviceTokenDTO
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type => "wtb_user_device_tokens";
|
||||
|
||||
[JsonPropertyName("deviceToken")]
|
||||
public string DeviceToken { get; set; }
|
||||
|
||||
[JsonPropertyName("userName")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[JsonPropertyName("appName")]
|
||||
public int AppName => 7; //salesbook
|
||||
|
||||
[JsonPropertyName("platform")]
|
||||
public string Platform { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using salesbook.Maui.Core.RestClient.IntegryApi.Dto;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
|
||||
namespace salesbook.Maui.Core.RestClient.IntegryApi;
|
||||
|
||||
public class IntegryNotificationRestClient(
|
||||
ILogger<IntegryNotificationRestClient> logger,
|
||||
IUserSession userSession,
|
||||
IIntegryApiRestClient integryApiRestClient
|
||||
) : IIntegryNotificationRestClient
|
||||
{
|
||||
public async Task Register(string fcmToken, ILogger? logger1 = null)
|
||||
{
|
||||
logger1 ??= logger;
|
||||
|
||||
var userDeviceToken = new RegisterDeviceDTO()
|
||||
{
|
||||
UserDeviceToken = new WtbUserDeviceTokenDTO()
|
||||
{
|
||||
DeviceToken = fcmToken,
|
||||
Platform = OperatingSystem.IsAndroid() ? "Android" : "iOS",
|
||||
Username = userSession.User.Username
|
||||
}
|
||||
};
|
||||
try
|
||||
{
|
||||
await integryApiRestClient.AuthorizedPost<object>($"device_tokens/insert", userDeviceToken,
|
||||
logger: logger1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user