Firebase FCM kliens működik
This commit is contained in:
@@ -15,7 +15,7 @@ public partial class LoginPage : BasePage
|
|||||||
public LoginPage()
|
public LoginPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InitFirebase();
|
|
||||||
SetContent(LoginContent);
|
SetContent(LoginContent);
|
||||||
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
||||||
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
||||||
@@ -35,10 +35,22 @@ public partial class LoginPage : BasePage
|
|||||||
if (response != null && response.IsSuccess)
|
if (response != null && response.IsSuccess)
|
||||||
{
|
{
|
||||||
_userService.SetCurrentUser(response.Data);
|
_userService.SetCurrentUser(response.Data);
|
||||||
SystemHelper.SystemUserDTO = response.Data;
|
SystemHelper.SystemUserDTO = response.Data;
|
||||||
|
|
||||||
|
var needFCM = false;
|
||||||
|
foreach (var role in response.Data.RoleDTO)
|
||||||
|
{
|
||||||
|
if (role.CanEnableBlocked)
|
||||||
|
{
|
||||||
|
needFCM = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needFCM)
|
||||||
|
{
|
||||||
|
await InitFirebase();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
||||||
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
||||||
await SecureStorage.Default.SetAsync("AuthToken", response.Data.JwtToken);
|
await SecureStorage.Default.SetAsync("AuthToken", response.Data.JwtToken);
|
||||||
@@ -169,7 +181,7 @@ public partial class LoginPage : BasePage
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void InitFirebase()
|
private async Task InitFirebase()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using Android.Content.PM;
|
using Android.Content.PM;
|
||||||
|
using Android.Media;
|
||||||
using Android.Nfc;
|
using Android.Nfc;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Firebase;
|
using Firebase;
|
||||||
@@ -103,11 +104,21 @@ namespace WorkFlowCheck.MAUI
|
|||||||
}
|
}
|
||||||
private void CreateNotificationChannel()
|
private void CreateNotificationChannel()
|
||||||
{
|
{
|
||||||
|
var soundUri = Android.Net.Uri.Parse($"android.resource://{Android.App.Application.Context.PackageName}/raw/siren_alert");
|
||||||
|
var audioAttributes = new AudioAttributes.Builder()
|
||||||
|
.SetUsage(AudioUsageKind.Notification)
|
||||||
|
.SetContentType(AudioContentType.Sonification)
|
||||||
|
.Build();
|
||||||
var channelId = $"{PackageName}.general";
|
var channelId = $"{PackageName}.general";
|
||||||
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
|
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
|
||||||
var channel = new NotificationChannel(channelId, "General", NotificationImportance.Default);
|
var channel = new NotificationChannel(channelId, "General", NotificationImportance.High);
|
||||||
|
|
||||||
|
channel.SetSound(soundUri, audioAttributes);
|
||||||
|
|
||||||
notificationManager.CreateNotificationChannel(channel);
|
notificationManager.CreateNotificationChannel(channel);
|
||||||
FirebaseCloudMessagingImplementation.ChannelId = channelId;
|
FirebaseCloudMessagingImplementation.ChannelId = channelId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
|||||||
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
|
Task<ApiResponseDTO<string>> SyncUsers_Up(Action<double, string> reportProgress);
|
||||||
Task SyncUsers_Down(Action<double, string> reportProgress);
|
Task SyncUsers_Down(Action<double, string> reportProgress);
|
||||||
|
|
||||||
Task<bool> UploadFCMToken(string token);
|
Task<ApiResponseDTO<bool>> UploadFCMToken(string token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user