/// <summary> /// Saves the notification log. /// </summary> /// <param name="notificationLogDto">The notification log dto.</param> /// <returns>NotificationLogDto object.</returns> public NotificationLogDto SaveNotificationLog(NotificationLogDto notificationLogDto) { try { NotificationLog notificationLog = this.mapperFactory.GetMapper<NotificationLogDto, NotificationLog>().Map(notificationLogDto); this.notificationLogRepository.Insert(notificationLog); this.notificationLogRepository.Commit(); } catch (Exception ex) { this.loggerService.LogException("notificationLogDto - " + ex.Message); } return notificationLogDto; }
/// <summary> /// Send Message Notification to Android Device /// </summary> /// <param name="gcmId">The GCMID </param> /// <param name="messageId">The Message Id</param> /// <param name="message">The Message Text</param> /// <param name="senderName">The sender name</param> /// <param name="type">The type of notification</param> /// <returns>bool object</returns> public bool SendMessageNotificationToAndroid(string gcmId, string messageId, string message, string senderName, string type = "") { message = "You have a new message from " + senderName + "."; try { this.pushBroker.QueueNotification(new GcmNotification().ForDeviceRegistrationId(gcmId) .WithJson("{\"data.message\":\"" + message + "\",\"data.messageid\":\"" + messageId + "\",\"data.type\":\"" + type + "\"}")); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = gcmId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.Android), IsSuccess = true }; this.SaveNotificationLog(notificationLogDto); } catch (Exception ex) { this.loggerService.LogException("SendMessageNotificationToAndroid = " + ex.Message); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = gcmId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.Android), IsSuccess = false }; this.SaveNotificationLog(notificationLogDto); return false; } return true; }
/// <summary> /// Sends the credit notification to ios. /// </summary> /// <param name="udId">The ud identifier.</param> /// <param name="messageId">The message identifier.</param> /// <param name="amount">The amount.</param> /// <param name="senderName">Name of the sender.</param> /// <param name="badge">The badge.</param> /// <param name="type">The type.</param> /// <returns>Boolean object.</returns> public bool SendCreditNotificationToiOS(string udId, string messageId, string amount, string senderName, int badge, string type = "") { string message = amount + " has been added to your account"; try { this.pushBroker.QueueNotification(new AppleNotification().ForDeviceToken(udId) .WithAlert(message) .WithCustomItem("messageId", messageId) .WithCustomItem("message", message) .WithCustomItem("type", type) .WithBadge(badge) .WithSound("sound.caf")); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = true }; this.SaveNotificationLog(notificationLogDto); } catch (Exception ex) { this.loggerService.LogException("SendCreditNotificationToiOS = " + ex.Message); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = false }; this.SaveNotificationLog(notificationLogDto); return false; } return true; }
/// <summary> /// Sends the purchased notification to iOS. /// </summary> /// <param name="udId">The UDID.</param> /// <param name="companyId">The company identifier.</param> /// <param name="companyname">The companyname.</param> /// <param name="message">The message.</param> /// <param name="type">The type.</param> /// <returns>Boolean object.</returns> public bool SendPurchasedNotificationToiOS(string udId, string companyId, string companyname, string message, string type = "") { message = "Congrats! you just made $5."; try { this.pushBroker.QueueNotification(new AppleNotification().ForDeviceToken(udId) .WithAlert(message) .WithCustomItem("companyId", companyId) .WithCustomItem("companyname", companyname) .WithCustomItem("message", message) .WithCustomItem("type", type) .WithSound("sound.caf")); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = true }; this.SaveNotificationLog(notificationLogDto); } catch (Exception ex) { this.loggerService.LogException("SendPurchasedNotificationToiOS = " + ex.Message); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = false }; this.SaveNotificationLog(notificationLogDto); return false; } return true; }
/// <summary> /// Sends the mark purchased notification to iOS. /// </summary> /// <param name="udId">The UDID.</param> /// <param name="markedByName">Name of the marked by.</param> /// <param name="markedById">The marked by identifier.</param> /// <param name="markedToName">Name of the marked to.</param> /// <param name="markedToId">The marked to identifier.</param> /// <param name="interest">The interest.</param> /// <param name="message">The message.</param> /// <param name="type">The type.</param> /// <returns>bool object</returns> public bool SendMarkPurchasedNotificationToiOS(string udId, string markedByName, string markedById, string markedToName, string markedToId, string interest, string message, string type = "") { message = markedByName + " has purchased " + (string.IsNullOrEmpty(markedToName) ? "you" : markedToName) + "."; try { this.pushBroker.QueueNotification(new AppleNotification().ForDeviceToken(udId) .WithAlert(message) .WithCustomItem("markedByName", markedByName) .WithCustomItem("markedById", markedById) .WithCustomItem("markedToName", markedToName) .WithCustomItem("markedToId", markedToId) .WithCustomItem("interest", interest) .WithCustomItem("message", message) .WithCustomItem("type", type) .WithSound("sound.caf")); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = true }; this.SaveNotificationLog(notificationLogDto); } catch (Exception ex) { this.loggerService.LogException("SendMarkPurchasedNotificationToiOS = " + ex.Message); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = false }; this.SaveNotificationLog(notificationLogDto); return false; } return true; }
/// <summary> /// Sends the not call again notification to iOS. /// </summary> /// <param name="udId">The UDID.</param> /// <param name="userId">The user identifier.</param> /// <param name="username">The username.</param> /// <param name="message">The message.</param> /// <param name="type">The type.</param> /// <returns>bool object</returns> public bool SendNotCallAgainNotificationToiOS(string udId, string userId, string username, string message, string type = "") { message = username + " has asked you not to call again."; try { this.pushBroker.QueueNotification(new AppleNotification().ForDeviceToken(udId) .WithAlert(message) .WithCustomItem("userId", userId) .WithCustomItem("username", username) .WithCustomItem("message", message) .WithCustomItem("type", type) .WithSound("sound.caf")); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = true }; this.SaveNotificationLog(notificationLogDto); } catch (Exception ex) { this.loggerService.LogException("SendNotCallAgainNotificationToiOS = " + ex.Message); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = udId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.iOS), IsSuccess = false }; this.SaveNotificationLog(notificationLogDto); return false; } return true; }
/// <summary> /// Sends the purchased notification to android. /// </summary> /// <param name="gcmId">The GCM Id.</param> /// <param name="companyId">The company identifier.</param> /// <param name="companyname">The companyname.</param> /// <param name="interest">The interest.</param> /// <param name="message">The message.</param> /// <param name="type">The type.</param> /// <returns>Boolean object.</returns> public bool SendPurchasedNotificationToAndroid(string gcmId, string companyId, string companyname, string interest, string message, string type = "") { message = "Congrats! you just made $5."; try { this.pushBroker.QueueNotification(new GcmNotification().ForDeviceRegistrationId(gcmId) .WithJson("{\"data.message\":\"" + message + "\",\"data.companyid\":\"" + companyId + "\",\"data.companyname\":\"" + companyname + "\",\"data.interest\":\"" + interest + "\",\"data.type\":\"" + type + "\"}")); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = gcmId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.Android), IsSuccess = true }; this.SaveNotificationLog(notificationLogDto); } catch (Exception ex) { this.loggerService.LogException("SendPurchasedNotificationToAndroid = " + ex.Message); NotificationLogDto notificationLogDto = new NotificationLogDto() { SentToId = gcmId, Message = message, NotificationType = type, OSType = Convert.ToInt32(OSType.Android), IsSuccess = false }; this.SaveNotificationLog(notificationLogDto); return false; } return true; }