X
This commit is contained in:
@@ -175,11 +175,16 @@ public partial class LoginPage : BasePage
|
||||
{
|
||||
await CrossFirebaseCloudMessaging.Current.CheckIfValidAsync();
|
||||
var token = await CrossFirebaseCloudMessaging.Current.GetTokenAsync();
|
||||
Console.WriteLine($"FCM token: {token}");
|
||||
|
||||
await _syncService.UploadFCMToken(token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("FCM init error: " + ex.Message);
|
||||
await SystemHelper.ShowSnackBar("FCM üzenetküldõ inicializálása SIKERTELEN!",
|
||||
SystemHelper.ColorToHex(Colors.Red),
|
||||
SystemHelper.ColorToHex(Colors.Red),
|
||||
SystemHelper.ColorToHex(Colors.Yellow),
|
||||
15);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,5 +512,40 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponseDTO<bool>> UploadFCMToken(string token)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<bool>();
|
||||
try
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/fcm/SendFCMToken";
|
||||
|
||||
var FCMMessageDTO = new FCMMessageDTO()
|
||||
{
|
||||
Token = token,
|
||||
UserId = _userService.GetCurrentUser()?.Id
|
||||
};
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, FCMMessageDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<bool>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<bool>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
return new ApiResponseDTO<bool>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user