Firebase FCM kliens működik
This commit is contained in:
@@ -15,7 +15,7 @@ public partial class LoginPage : BasePage
|
||||
public LoginPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitFirebase();
|
||||
|
||||
SetContent(LoginContent);
|
||||
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
||||
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
||||
@@ -37,7 +37,19 @@ public partial class LoginPage : BasePage
|
||||
_userService.SetCurrentUser(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);
|
||||
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
||||
@@ -169,7 +181,7 @@ public partial class LoginPage : BasePage
|
||||
|
||||
}
|
||||
|
||||
private async void InitFirebase()
|
||||
private async Task InitFirebase()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.Media;
|
||||
using Android.Nfc;
|
||||
using Android.OS;
|
||||
using Firebase;
|
||||
@@ -103,11 +104,21 @@ namespace WorkFlowCheck.MAUI
|
||||
}
|
||||
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 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);
|
||||
FirebaseCloudMessagingImplementation.ChannelId = channelId;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,6 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
||||
Task<ApiResponseDTO<string>> SyncUsers_Up(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