Example #1
0
        public async Task Send(Notification notification)
        {
            // create the notification to validate it
            if (notification.Id == 0)
            {
                notification.Id = this.services.Settings.IncrementValue("NotificationId");
            }

            var builder = new ToastContentBuilder()
                          .AddText(notification.Title, AdaptiveTextStyle.Title)
                          .AddText(notification.Message, AdaptiveTextStyle.Subtitle)
                          .SetToastDuration(ToastDuration.Short)
                          .AddToastActivationInfo(notification.Id.ToString(), ToastActivationType.Foreground);

            await this.TrySetChannel(notification, builder);

            if (notification.ScheduleDate != null)
            {
                await this.services.Repository.Set(notification.Id.ToString(), notification);

                // TODO: set badge and fire notification fired?
                builder.Schedule(notification.ScheduleDate.Value);
            }
            else
            {
                if (notification.BadgeCount != null)
                {
                    this.Badge = notification.BadgeCount.Value;
                }

                builder.Show(new CustomizeToast(x =>
                {
                    //x.Activated += null;
                    //x.Dismissed += null;
                    x.Tag = notification.Id.ToString();
                    //x.Group = "";
                    //x.Priority
                }));
            }
        }