public async Task <long> SendNotification(Request model, int type, string senderName, string refusemsg = "") { NotificationType notificationType = (NotificationType)type; var arMessage = notificationType.GetStringValue(); var devicesList = _UnitOfWork.DeviceSettingRepository.All().Include(u => u.ApplicationUser); arMessage = arMessage.Replace("####", senderName); if (type == 4 || type == 7) { arMessage += "بسبب :"; arMessage += refusemsg; } Attachment attachment; var content = BuildNotificationContent(model, arMessage, out attachment); HashSet <string> hashSet = new HashSet <string>(); //save message vs message device vs Return Device Ids var messageId = SaveMessageVsReturnsDeviceIds(model, type, arMessage, notificationType, devicesList, ref hashSet); // send notification using one signal if (hashSet.Any()) { Device device = new Device(hashSet); var send = client.SendNotification(device, content, attachment, null); } return(messageId); }