diff --git a/BCS.BMC/src/BCS.BMC.Application/BCS.BMC.Application.csproj b/BCS.BMC/src/BCS.BMC.Application/BCS.BMC.Application.csproj
index a06c046..77bbad6 100644
--- a/BCS.BMC/src/BCS.BMC.Application/BCS.BMC.Application.csproj
+++ b/BCS.BMC/src/BCS.BMC.Application/BCS.BMC.Application.csproj
@@ -18,6 +18,7 @@
+
diff --git a/BCS.BMC/src/BCS.BMC.Application/CompanyMasters/CompanyMasterAppService.cs b/BCS.BMC/src/BCS.BMC.Application/CompanyMasters/CompanyMasterAppService.cs
index a0d9679..de3ebca 100644
--- a/BCS.BMC/src/BCS.BMC.Application/CompanyMasters/CompanyMasterAppService.cs
+++ b/BCS.BMC/src/BCS.BMC.Application/CompanyMasters/CompanyMasterAppService.cs
@@ -166,12 +166,26 @@ namespace BCS.BMC.CompanyMasters
//throw new UserFriendlyException(NotFoundRecord ("Name", input.ClientName));
throw new UserFriendlyException("No Record Found");
}
-
+
var getclient = from m in _companyMaster.GetAllList()
.Where(m => m.Id == input.Id && m.CompanyName.ToLower().Trim() == input.CompanyName.ToLower().Trim() && m.Id != input.Id)
select m;
input.MapTo(entity);
+ Uri uri = new Uri(input.Url, UriKind.Absolute);
+ var host = uri.Host;
+
+ if (host.Split('.').Length > 2)
+ {
+ int lastIndex = host.LastIndexOf(".");
+ int index = host.LastIndexOf(".", lastIndex - 1);
+ var subdomain = host.Substring(0, index);
+ if (subdomain != "www")
+ {
+ entity.SubDomainName = subdomain;
+ }
+ }
+ entity.DomainName = host;
if (getclient == null || getclient.Count() == 0)
{
await _companyMaster.UpdateAsync(entity);
diff --git a/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FcmNotificationSetting.cs b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FcmNotificationSetting.cs
new file mode 100755
index 0000000..190b1b0
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FcmNotificationSetting.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BCS.BMC.FirebaseCloudMessaging.Dto
+{
+ public class FcmNotificationSetting
+ {
+ public string SenderId { get; set; }
+ public string ServerKey { get; set; }
+ }
+}
diff --git a/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FirebaseResponseModel.cs b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FirebaseResponseModel.cs
new file mode 100755
index 0000000..04e40d0
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FirebaseResponseModel.cs
@@ -0,0 +1,17 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BCS.BMC.FirebaseCloudMessaging.Dto
+{
+ public class FireBaseResponseModel
+ {
+ [JsonProperty("isSuccess")]
+ public bool IsSuccess { get; set; }
+ [JsonProperty("message")]
+ public string Message { get; set; }
+ }
+}
diff --git a/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs
new file mode 100644
index 0000000..cada993
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs
@@ -0,0 +1,38 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BCS.BMC.FirebaseCloudMessaging.Dto
+{
+ public class NotificationModel
+ {
+ [JsonProperty("deviceId")]
+ public string DeviceId { get; set; }
+ [JsonProperty("isAndroidDevice")]
+ public bool IsAndroidDevice { get; set; }
+ [JsonProperty("title")]
+ public string Title { get; set; }
+ [JsonProperty("body")]
+ public string Body { get; set; }
+ }
+
+ public class GoogleNotification
+ {
+ public class DataPayload
+ {
+ [JsonProperty("title")]
+ public string Title { get; set; }
+ [JsonProperty("body")]
+ public string Body { get; set; }
+ }
+ [JsonProperty("priority")]
+ public string Priority { get; set; } = "high";
+ [JsonProperty("data")]
+ public DataPayload Data { get; set; }
+ [JsonProperty("notification")]
+ public DataPayload Notification { get; set; }
+ }
+}
diff --git a/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/FirebaseNotificationAppService.cs b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/FirebaseNotificationAppService.cs
new file mode 100644
index 0000000..710865a
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/FirebaseNotificationAppService.cs
@@ -0,0 +1,44 @@
+using FirebaseAdmin.Messaging;
+using System.Threading.Tasks;
+using FirebaseAdmin;
+using Google.Apis.Auth.OAuth2;
+using System;
+
+
+namespace BCS.BMC.FirebaseCloudMessaging
+{
+ public class FirebaseNotificationAppService : IFirebaseNotificationAppService
+ {
+
+ public FirebaseNotificationAppService()
+ {
+ if (FirebaseApp.DefaultInstance is null)
+ {
+ FirebaseApp.Create(new AppOptions()
+ {
+ Credential = GoogleCredential.FromFile("firechat-57601-firebase-adminsdk-anscp-e04366c4d4.json")
+ });
+ }
+ }
+
+
+ public static async Task SendNotification(string fcmToken, Notification notification)
+ {
+ try
+ {
+ var message = new Message()
+ {
+ Notification = notification,
+ Token = fcmToken,
+ };
+
+ return await FirebaseMessaging.DefaultInstance.SendAsync(message) ;
+
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+ }
+}
diff --git a/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/IFirebaseNotificationAppService.cs b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/IFirebaseNotificationAppService.cs
new file mode 100644
index 0000000..24716f9
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/IFirebaseNotificationAppService.cs
@@ -0,0 +1,11 @@
+using Abp.Application.Services;
+using FirebaseAdmin.Messaging;
+using System.Threading.Tasks;
+
+namespace BCS.BMC.FirebaseCloudMessaging
+{
+ public interface IFirebaseNotificationAppService : IApplicationService
+ {
+ // Task SendNotification(string fcmToken, Notification notification);
+ }
+}
diff --git a/BCS.BMC/src/BCS.BMC.Web.Core/Models/TokenAuth/LoginInputModel.cs b/BCS.BMC/src/BCS.BMC.Web.Core/Models/TokenAuth/LoginInputModel.cs
index 0a26ed3..f5a7026 100644
--- a/BCS.BMC/src/BCS.BMC.Web.Core/Models/TokenAuth/LoginInputModel.cs
+++ b/BCS.BMC/src/BCS.BMC.Web.Core/Models/TokenAuth/LoginInputModel.cs
@@ -11,5 +11,6 @@ namespace BCS.BMC.Models.TokenAuth
public string CompanyUrl { get; set; }
public string UsernameOrEmailAddress { get; set; }
public string Password { get; set; }
+ public string FcmToken { get; set; }
}
}
diff --git a/BCS.BMC/src/BCS.BMC.Web.Mvc/BCS.BMC.Web.Mvc.csproj b/BCS.BMC/src/BCS.BMC.Web.Mvc/BCS.BMC.Web.Mvc.csproj
index 7315deb..3878303 100644
--- a/BCS.BMC/src/BCS.BMC.Web.Mvc/BCS.BMC.Web.Mvc.csproj
+++ b/BCS.BMC/src/BCS.BMC.Web.Mvc/BCS.BMC.Web.Mvc.csproj
@@ -42,6 +42,7 @@
+
diff --git a/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/FirebaseNotificationController.cs b/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/FirebaseNotificationController.cs
new file mode 100644
index 0000000..1d10cc0
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/FirebaseNotificationController.cs
@@ -0,0 +1,29 @@
+using BCS.BMC.Controllers;
+using BCS.BMC.FirebaseCloudMessaging;
+using FirebaseAdmin.Messaging;
+using Microsoft.AspNetCore.Mvc;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace BCS.BMC.Web.Controllers
+{
+ //[Route("api/notification")]
+ //[ApiController]
+ public class FirebaseNotificationController : BMCControllerBase
+ {
+ private readonly FirebaseNotificationAppService _notificationService;
+
+ public FirebaseNotificationController(FirebaseNotificationAppService notificationService)
+ {
+ _notificationService = notificationService;
+ }
+
+ [Route("send")]
+ [HttpPost]
+ public async Task Notification(string fcmToken, [FromBody] Notification notification)
+ {
+ var result = await FirebaseNotificationAppService.SendNotification(fcmToken, notification);
+ return Ok(result);
+ }
+ }
+}
diff --git a/BCS.BMC/src/BCS.BMC.Web.Mvc/firechat-57601-firebase-adminsdk-anscp-e04366c4d4.json b/BCS.BMC/src/BCS.BMC.Web.Mvc/firechat-57601-firebase-adminsdk-anscp-e04366c4d4.json
new file mode 100644
index 0000000..1ffa1dd
--- /dev/null
+++ b/BCS.BMC/src/BCS.BMC.Web.Mvc/firechat-57601-firebase-adminsdk-anscp-e04366c4d4.json
@@ -0,0 +1,12 @@
+{
+ "type": "service_account",
+ "project_id": "firechat-57601",
+ "private_key_id": "e04366c4d4ad7167925421faaf7daf868cd5c686",
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCZwdt1kWg3mX8/\nXAdaECug6Kp9d3cfXshJLjZRtzUyeC7nkE10Ld0hhgxUH/5Fopu2vjTM0eq3NSNi\nte2ulpcEf4yObF5ZQEIeBvdf7uhvnvk1T+o/OcldkFyybWxSzCLwHWrS+eNkxKKP\nCbpXQuZ5v5g95p9FGFr9zM29gMB1FH1l0IiOh5UwGpTo39Glsdalw7OFDKYkWl0u\noGQ0qsO+As/MQKyYw4cJqIz6h8CX4WuloZhfKLv+KW8jwjN01UrlRNJQiJazSHYV\nLb9sP9WkGnVRnhXNtUy/vy6Cd5xSmd1wCPByNao04tlXPdBSwydqPsBmFjsSUX9V\nYg9Y5X6dAgMBAAECggEAEPr6x0TJXf04CKxGLOkaQwlO7XpIZTuCIlWAhDfCdTzB\nRADeEkA6ap2zi4WDqaG9UUo3lI3I6SDCNAA5gTgk8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3PG\n7vPIsrfNuONkc13uhWF4YtvANcx2rhLxma84Ey5Ai2kvx6fer+BRRK3Wr36n3AEw\nssODLddJnZESSdlIdsghLw==\n-----END PRIVATE KEY-----\n",
+ "client_email": "firebase-adminsdk-anscp@firechat-57601.iam.gserviceaccount.com",
+ "client_id": "101896998053383660888",
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
+ "token_uri": "https://oauth2.googleapis.com/token",
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-anscp%40firechat-57601.iam.gserviceaccount.com"
+}