|
|
@ -6,13 +6,15 @@ using System; |
|
|
|
using BCS.BMC.FirebaseCloudMessaging.Dto; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Abp.Json; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
|
|
|
namespace BCS.BMC.FirebaseCloudMessaging |
|
|
|
{ |
|
|
|
public class FirebaseNotificationAppService : IFirebaseNotificationAppService |
|
|
|
{ |
|
|
|
private readonly ILogger _logger; |
|
|
|
|
|
|
|
public FirebaseNotificationAppService() |
|
|
|
public FirebaseNotificationAppService(ILogger logger) |
|
|
|
{ |
|
|
|
if (FirebaseApp.DefaultInstance is null) |
|
|
|
{ |
|
|
@ -21,27 +23,31 @@ namespace BCS.BMC.FirebaseCloudMessaging |
|
|
|
Credential = GoogleCredential.FromFile("firechat-57601-firebase-adminsdk-anscp-e04366c4d4.json") |
|
|
|
}); |
|
|
|
} |
|
|
|
_logger = logger; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static async Task<BatchResponse> SendNotification( FireBaseResponseModel notification) |
|
|
|
public async Task<BatchResponse> SendNotification(FireBaseResponseModel notification) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
|
|
|
|
var message = new MulticastMessage() |
|
|
|
{ |
|
|
|
Notification = notification.notification, |
|
|
|
Tokens = notification.FcmToken, |
|
|
|
}; |
|
|
|
var message = new MulticastMessage() |
|
|
|
{ |
|
|
|
Notification = notification.notification, |
|
|
|
Tokens = notification.FcmToken, |
|
|
|
}; |
|
|
|
|
|
|
|
var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(message); |
|
|
|
return response; |
|
|
|
} |
|
|
|
catch(Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public async Task GetNotification(NotificationModel notification) |
|
|
|
{ |
|
|
|
_logger.LogInformation("Bwac Notifications" + notification); |
|
|
|
} |
|
|
|
} |
|
|
|
} |