Пример #1
0
        public override Task Send(Notification notification) => this.Invoke(() =>
        {
            if (notification.Id == null)
            {
                notification.GeneratedNotificationId();
            }

            // untested
            if (string.IsNullOrEmpty(notification.Sound))
            {
                if (!string.IsNullOrEmpty(Notification.DefaultSound))
                {
                    notification.Sound = Notification.DefaultSound;
                }
                else if (Notification.SystemSoundFallback)
                {
                    notification.Sound = NSUserNotification.NSUserNotificationDefaultSoundName;
                }
            }

            var native = new NSUserNotification
            {
                Identifier      = notification.Id.Value.ToString(),
                Title           = notification.Title,
                InformativeText = notification.Message,
                SoundName       = notification.Sound,
                DeliveryDate    = notification.SendTime.ToNSDate(),
                UserInfo        = notification.Metadata.ToNsDictionary()
            };
            NSUserNotificationCenter
            .DefaultUserNotificationCenter
            .ScheduleNotification(native);
        });
Пример #2
0
        public override Task Send(Notification notification) => this.Invoke(async() =>
        {
            if (notification.Id == null)
            {
                notification.GeneratedNotificationId();
            }

            var content = new UNMutableNotificationContent
            {
                Title = notification.Title,
                Body  = notification.Message
            };
            if (!String.IsNullOrWhiteSpace(notification.Sound))
            {
                content.Sound = UNNotificationSound.GetSound(notification.Sound);
            }

            var dt      = notification.SendTime;
            var request = UNNotificationRequest.FromIdentifier(
                notification.Id.Value.ToString(),
                content,
                UNCalendarNotificationTrigger.CreateTrigger(new NSDateComponents
            {
                Year   = dt.Year,
                Month  = dt.Month,
                Day    = dt.Day,
                Hour   = dt.Hour,
                Minute = dt.Minute,
                Second = dt.Second
            }, false)
                );
            await UNUserNotificationCenter.Current.AddNotificationRequestAsync(request);
        });
Пример #3
0
        public override Task Send(Notification notification) => this.Invoke(async() =>
        {
            if (notification.Id == null)
            {
                notification.GeneratedNotificationId();
            }

            var content = new UNMutableNotificationContent
            {
                Title           = notification.Title,
                Body            = notification.Message,
                LaunchImageName = notification.IconName
            };

            if (string.IsNullOrEmpty(notification.Sound))
            {
                if (!string.IsNullOrEmpty(Notification.DefaultSound))
                {
                    notification.Sound = Notification.DefaultSound;
                    content.Sound      = UNNotificationSound.GetSound(notification.Sound);
                }
                else if (Notification.SystemSoundFallback)
                {
                    // untested
                    content.Sound = UNNotificationSound.Default;
                }
            }
            else
            {
                content.Sound = UNNotificationSound.GetSound(notification.Sound);
            }

            var dt      = notification.SendTime;
            var request = UNNotificationRequest.FromIdentifier(
                notification.Id.Value.ToString(),
                content,
                UNCalendarNotificationTrigger.CreateTrigger(new NSDateComponents
            {
                Year   = dt.Year,
                Month  = dt.Month,
                Day    = dt.Day,
                Hour   = dt.Hour,
                Minute = dt.Minute,
                Second = dt.Second
            }, false)
                );
            await UNUserNotificationCenter.Current.AddNotificationRequestAsync(request);
        });
Пример #4
0
        public override Task Send(Notification notification)
        {
            if (notification.Id == null)
            {
                notification.GeneratedNotificationId();
            }

            notification.Metadata.Add(NOTIFICATION_ID_KEY, notification.Id.ToString());

            var not = new UILocalNotification
            {
                FireDate   = notification.SendTime.ToNSDate(),
                AlertTitle = notification.Title,
                AlertBody  = notification.Message,
                SoundName  = notification.Sound,
                UserInfo   = notification.Metadata.ToNsDictionary()
            };

            return(this.Invoke(() => UIApplication.SharedApplication.ScheduleLocalNotification(not)));
        }
        public override Task Send(Notification notification) => this.Invoke(() =>
        {
            if (notification.Id == null)
            {
                notification.GeneratedNotificationId();
            }

            var native = new NSUserNotification
            {
                Identifier      = notification.Id.Value.ToString(),
                Title           = notification.Title,
                InformativeText = notification.Message,
                SoundName       = notification.Sound,
                DeliveryDate    = notification.SendTime.ToNSDate(),
                UserInfo        = notification.Metadata.ToNsDictionary()
            };
            NSUserNotificationCenter
            .DefaultUserNotificationCenter
            .ScheduleNotification(native);
        });
        public override Task Send(Notification notification)
        {
            if (notification.Id == null)
            {
                notification.GeneratedNotificationId();
            }

            notification.Metadata.Add(NOTIFICATION_ID_KEY, notification.Id.ToString());

            if (string.IsNullOrEmpty(notification.Sound))
            {
                if (!String.IsNullOrEmpty(Notification.DefaultSound))
                {
                    notification.Sound = Notification.DefaultSound;
                }

                else if (Notification.SystemSoundFallback)
                {
                    notification.Sound = UILocalNotification.DefaultSoundName;
                }
            }

            //if (string.IsNullOrEmpty(notification.IconName))
            //{
            //    notification.IconName = Notification.DefaultIcon;
            //}

            var not = new UILocalNotification
            {
                FireDate         = notification.SendTime.ToNSDate(),
                AlertTitle       = notification.Title,
                AlertBody        = notification.Message,
                SoundName        = notification.Sound,
                AlertLaunchImage = notification.IconName,
                UserInfo         = notification.Metadata.ToNsDictionary()
            };

            return(this.Invoke(() => UIApplication.SharedApplication.ScheduleLocalNotification(not)));
        }