APNsTools.cs 1.2 KB

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