/// <summary> /// Queue a notification with the given parameters. /// </summary> /// <param name="title">The title for the notification.</param> /// <param name="body">The body text for the notification.</param> /// <param name="deliveryTime">The time to deliver the notification.</param> /// <param name="badgeNumber">The optional badge number to display on the application icon.</param> /// <param name="reschedule"> /// Whether to reschedule the notification if foregrounding and the notification hasn't yet been shown. /// </param> /// <param name="channelId">Channel ID to use. If this is null/empty then it will use the default ID. For Android /// the channel must be registered in <see cref="GameNotificationsManager.Initialize"/>.</param> /// <param name="smallIcon">Notification small icon.</param> /// <param name="largeIcon">Notification large icon.</param> public void SendNotification(string title, string body, DateTime deliveryTime, int?badgeNumber = null, bool reschedule = false, string channelId = null, string smallIcon = null, string largeIcon = null) { IGameNotification notification = manager.CreateNotification(); if (notification == null) { return; } notification.Title = title; notification.Body = body; notification.Group = !string.IsNullOrEmpty(channelId) ? channelId : ChannelId; notification.DeliveryTime = deliveryTime; notification.SmallIcon = smallIcon; notification.LargeIcon = largeIcon; if (badgeNumber != null) { notification.BadgeNumber = badgeNumber; } PendingNotification notificationToDisplay = manager.ScheduleNotification(notification); notificationToDisplay.Reschedule = reschedule; updatePendingNotifications = true; QueueEvent($"Queued event with ID \"{notification.Id}\" at time {deliveryTime:HH:mm}"); }
public void SendNotification(string title, string body, DateTime deliveryTime, int?badgeNumber = null, bool reschedule = false, string channelId = null, string smallIcon = null, string largeIcon = null) { IGameNotification notification = manager.CreateNotification(); if (notification == null) { return; } notification.Title = title; notification.Body = body; notification.Group = !string.IsNullOrEmpty(channelId) ? channelId : NOTIFICATION_CHANNEL_ID; notification.DeliveryTime = deliveryTime; notification.SmallIcon = smallIcon; notification.LargeIcon = largeIcon; if (badgeNumber != null) { notification.BadgeNumber = badgeNumber; } PendingNotification notificationToDisplay = manager.ScheduleNotification(notification); notificationToDisplay.Reschedule = reschedule; // Debug.Log($"Queued notification for unactivity with ID \"{notification.Id}\" at time {deliveryTime:dd.MM.yyyy HH:mm:ss}"); }
/// <summary> /// Cancel a given pending notification /// </summary> public void CancelPendingNotificationItem(PendingNotification itemToCancel) { manager.CancelNotification(itemToCancel.Notification.Id.Value); updatePendingNotifications = true; QueueEvent($"Cancelled notification with ID \"{itemToCancel.Notification.Id}\""); }
public async Task Handle(SendEmailCommand command) { var notification = new PendingNotification(command.Id, command.To, command.Subject, command.Body); var content = JsonConvert.SerializeObject(notification); await _httpClient.PostAsync(_notificationsApiSettings.Path, new StringContent(content, Encoding.UTF8, "application/json")); }
private void DisplayPendingNotification() { StringBuilder notificationStringBuilder = new StringBuilder("Pending notifications at:"); notificationStringBuilder.AppendLine(); for (int i = manager.PendingNotifications.Count - 1; i >= 0; --i) { PendingNotification queuedNotification = manager.PendingNotifications[i]; DateTime? time = queuedNotification.Notification.DeliveryTime; if (time != null) { notificationStringBuilder.Append($"{time:dd.MM.yyyy HH:mm:ss}"); notificationStringBuilder.AppendLine(); } } notificationScheduledText.text = notificationStringBuilder.ToString(); }
/// <summary> /// Show for a given pending notification. /// </summary> public void Show(PendingNotification notificationToDisplay, NotificationConsole containingConsole) { notification = notificationToDisplay; console = containingConsole; if (idLabel != null && notificationToDisplay.Notification.Id.HasValue) { idLabel.text = notificationToDisplay.Notification.Id.Value.ToString(); } if (titleLabel != null) { titleLabel.text = notificationToDisplay.Notification.Title; } if (timeLabel != null && notificationToDisplay.Notification.DeliveryTime.HasValue) { timeLabel.text = notificationToDisplay.Notification.DeliveryTime.Value.ToString("yy-MM-dd HH:mm:ss"); } }
private void OnExpired(PendingNotification obj) { QueueEvent($"Notification with title \"{obj.Notification.Title}\" expired and was not displayed."); }
private void OnDelivered(PendingNotification deliveredNotification) { // Schedule this to run on the next frame (can't create UI elements from a Java callback) StartCoroutine(ShowDeliveryNotificationCoroutine(deliveredNotification.Notification)); }