FCM kifejlesztése
This commit is contained in:
@@ -30,39 +30,7 @@ namespace WorkFlowCheck.API.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
var pathToJsonKey = "com-nuvolar-wfcapp-firebase-adminsdk-fbsvc-37642626e4.json";
|
||||
var projectId = "com-nuvolar-wfcapp";
|
||||
var credential = GoogleCredential
|
||||
.FromFile(pathToJsonKey)
|
||||
.CreateScoped("https://www.googleapis.com/auth/firebase.messaging");
|
||||
var accessToken = await credential.UnderlyingCredential.GetAccessTokenForRequestAsync();
|
||||
|
||||
var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
|
||||
|
||||
var message = new
|
||||
{
|
||||
message = new
|
||||
{
|
||||
token = fCMMessageDTO.Token,
|
||||
notification = new
|
||||
{
|
||||
title = fCMMessageDTO.Title,
|
||||
body = fCMMessageDTO.Body,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var json = JsonConvert.SerializeObject(message);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
|
||||
var response = await client.PostAsync($"https://fcm.googleapis.com/v1/projects/{projectId}/messages:send", content);
|
||||
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
retVal.IsSuccess = await _messageService.SendFCMMessage(fCMMessageDTO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -82,39 +50,7 @@ namespace WorkFlowCheck.API.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
var pathToJsonKey = "com-nuvolar-wfcapp-firebase-adminsdk-fbsvc-37642626e4.json";
|
||||
var projectId = "com-nuvolar-wfcapp";
|
||||
var credential = GoogleCredential
|
||||
.FromFile(pathToJsonKey)
|
||||
.CreateScoped("https://www.googleapis.com/auth/firebase.messaging");
|
||||
var accessToken = await credential.UnderlyingCredential.GetAccessTokenForRequestAsync();
|
||||
|
||||
var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
|
||||
|
||||
var message = new
|
||||
{
|
||||
message = new
|
||||
{
|
||||
token = await _messageService.GetLastFCMTokensAsync(),
|
||||
notification = new
|
||||
{
|
||||
title = fCMMessageDTO.Title,
|
||||
body = fCMMessageDTO.Body,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var json = JsonConvert.SerializeObject(message);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
|
||||
var response = await client.PostAsync($"https://fcm.googleapis.com/v1/projects/{projectId}/messages:send", content);
|
||||
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
retVal.IsSuccess = await _messageService.SendFCMMessageToLastToken(fCMMessageDTO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFC;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"
|
||||
"DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFCUAT;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user