APNsTools.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using EyeSoft.Runtime.InteropServices;
  2. using OASystem.API.Controllers;
  3. using OASystem.API.OAMethodLib.Hub.Hubs;
  4. using OASystem.Domain.Entities.Groups;
  5. using OASystem.Infrastructure.Repositories.Login;
  6. namespace OASystem.API.OAMethodLib.APNs
  7. {
  8. public static class APNsTools
  9. {
  10. private static readonly DeviceTokenRepository _deviceTokenRep = AutofacIocManager.Instance.GetService<DeviceTokenRepository>();
  11. //private static readonly IAPNsService _APNsService = AutofacIocManager.Instance.GetService<IAPNsService>();
  12. public static async Task<Result> iOS_PushNotifications(string Numbers, string title, string subtitle, string body)
  13. {
  14. Result rst2 = new Result() { Code = -1, Msg = "" };
  15. try
  16. {
  17. var _APNsService = AutofacIocManager.Instance.GetService<IAPNsService>();
  18. var rst = await _deviceTokenRep.Query(s => s.Number == Numbers).FirstAsync();
  19. //var rst = new Sys_DeviceToken() { DeviceToken = "08be7ba1ee42ecf36f695fd6b795b5e203295eaed0ba3857276141dbeee025ff" }
  20. if (rst != null)
  21. {
  22. rst2 = await _APNsService.PushNotification("com.panamerican.oa2024", rst.DeviceToken, NotificationType.Alert, title, subtitle, body);
  23. }
  24. }
  25. catch (Exception ex)
  26. {
  27. }
  28. return rst2;
  29. }
  30. }
  31. }