BMC: Install FireShip sdk
This commit is contained in:
parent
2750b3d25e
commit
c93955df68
@ -19,6 +19,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FirebaseAdmin" Version="2.3.0" />
|
<PackageReference Include="FirebaseAdmin" Version="2.3.0" />
|
||||||
|
<PackageReference Include="FireSharp" Version="2.0.4" />
|
||||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.9" />
|
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.9" />
|
||||||
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" />
|
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,22 +1,34 @@
|
|||||||
using Newtonsoft.Json;
|
using Abp.AutoMapper;
|
||||||
|
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||||
{
|
{
|
||||||
|
[AutoMapTo(typeof (FirebaseCloudMessageDetails))]
|
||||||
public class NotificationModel
|
public class NotificationModel
|
||||||
{
|
{
|
||||||
//[JsonProperty("deviceId")]
|
//[JsonProperty("deviceId")]
|
||||||
//public string DeviceId { get; set; }
|
//public string DeviceId { get; set; }
|
||||||
//[JsonProperty("isAndroidDevice")]
|
//[JsonProperty("isAndroidDevice")]
|
||||||
//public bool IsAndroidDevice { get; set; }
|
//public bool IsAndroidDevice { get; set; }
|
||||||
|
public string Id { get; set; }
|
||||||
[JsonProperty("title")]
|
[JsonProperty("title")]
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
[JsonProperty("body")]
|
[JsonProperty("body")]
|
||||||
public string Body { get; set; }
|
public string Body { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public string FcmToken { get; set; }
|
||||||
|
public string SenderImageurl { get; set; }
|
||||||
|
public string SenderName { get; set; }
|
||||||
|
public DateTime? MessageSentDateTime { get; set; }
|
||||||
|
public bool Status { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GoogleNotification
|
public class GoogleNotification
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
||||||
|
<PackageReference Include="FireSharp" Version="2.0.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.4" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.4">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
using Abp.Json;
|
using Abp.AutoMapper;
|
||||||
|
using Abp.Domain.Repositories;
|
||||||
|
using Abp.Json;
|
||||||
|
using BCS.BMC.BMC.CompanyMasters;
|
||||||
|
using BCS.BMC.BMC.FirebaseCloudMessages;
|
||||||
using BCS.BMC.Controllers;
|
using BCS.BMC.Controllers;
|
||||||
using BCS.BMC.FirebaseCloudMessaging;
|
using BCS.BMC.FirebaseCloudMessaging;
|
||||||
using BCS.BMC.FirebaseCloudMessaging.Dto;
|
using BCS.BMC.FirebaseCloudMessaging.Dto;
|
||||||
using BCS.BMC.Models.TokenAuth;
|
using BCS.BMC.Models.TokenAuth;
|
||||||
using FirebaseAdmin.Messaging;
|
using FirebaseAdmin.Messaging;
|
||||||
|
using FireSharp.Config;
|
||||||
|
using FireSharp.Interfaces;
|
||||||
|
using FireSharp.Response;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -16,10 +23,20 @@ namespace BCS.BMC.Web.Controllers
|
|||||||
public class NotificationController : BMCControllerBase
|
public class NotificationController : BMCControllerBase
|
||||||
{
|
{
|
||||||
private readonly IFirebaseNotificationAppService _notificationService;
|
private readonly IFirebaseNotificationAppService _notificationService;
|
||||||
|
private readonly IRepository<FirebaseCloudMessageDetails> _firebaseCloudMessageDetails;
|
||||||
public NotificationController(IFirebaseNotificationAppService notificationService)
|
IFirebaseConfig config = new FirebaseConfig
|
||||||
|
{
|
||||||
|
AuthSecret = "n6DTPQEbpnLahrrk2EYu4bJ2Wd3jCk2N8kocazdI",
|
||||||
|
BasePath = "https://firechat-57601-default-rtdb.europe-west1.firebasedatabase.app/"
|
||||||
|
};
|
||||||
|
IFirebaseClient client;
|
||||||
|
public NotificationController(IFirebaseNotificationAppService notificationService,
|
||||||
|
IRepository<FirebaseCloudMessageDetails> firebaseCloudMessageDetails)
|
||||||
{
|
{
|
||||||
_notificationService = notificationService;
|
_notificationService = notificationService;
|
||||||
|
_firebaseCloudMessageDetails = firebaseCloudMessageDetails;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,6 +50,22 @@ namespace BCS.BMC.Web.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GetNotifications([FromBody]NotificationModel notification)
|
public async Task<IActionResult> GetNotifications([FromBody]NotificationModel notification)
|
||||||
{
|
{
|
||||||
|
client = new FireSharp.FirebaseClient(config);
|
||||||
|
var data = notification;
|
||||||
|
PushResponse response = client.Push("notification/", data);
|
||||||
|
data.Id = response.Result.name;
|
||||||
|
SetResponse setResponse = client.Set("notification/" + data.Id, data);
|
||||||
|
if (setResponse.StatusCode == System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
ModelState.AddModelError(string.Empty, "Added Succesfully");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModelState.AddModelError(string.Empty, "Something went wrong!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var entity = notification.MapTo<FirebaseCloudMessageDetails>();
|
||||||
|
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity);
|
||||||
// var result = _notificationService.GetNotification(notification);
|
// var result = _notificationService.GetNotification(notification);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user