/// <summary>
        /// Schedule a local notification in the Notification Area and Drawer.
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        /// <param name="id">Id of the notification</param>
        /// <param name="notifyTime">The time you would like to schedule the notification for</param>
        public void Show(string title, string body, int id, DateTime notifyTime)
        {
            var intent = CreateIntent(id);

            var localNotification = new LocalNotification();
            localNotification.Title = title;
            localNotification.Body = body;
            localNotification.Id = id;
            localNotification.NotifyTime = notifyTime;
            if (NotificationIconId != 0)
            {
                localNotification.IconId = NotificationIconId;
            }
            else
            {
                localNotification.IconId = Resource.Drawable.plugin_lc_smallicon;
            }

            var serializedNotification = SerializeNotification(localNotification);
            intent.PutExtra(ScheduledAlarmHandler.LocalNotificationKey, serializedNotification);

            var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, intent, PendingIntentFlags.CancelCurrent);
            var triggerTime = NotifyTimeInMilliseconds(localNotification.NotifyTime);
            var alarmManager = GetAlarmManager();

            alarmManager.Set(AlarmType.RtcWakeup, triggerTime, pendingIntent);
        }
 private string SerializeNotification(LocalNotification notification)
 {
     var xmlSerializer = new XmlSerializer(notification.GetType());
     using (var stringWriter = new StringWriter())
     {
         xmlSerializer.Serialize(stringWriter, notification);
         return stringWriter.ToString();
     }
 }
        /// <summary>
        /// Show a local notification at a specified time
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        /// <param name="id">Id of the notification</param>
        /// <param name="notifyTime">Time to show notification</param>
        /// <param name="repeat">Set up repeat on notification</param>
        public void Show(string title, string body, int id, DateTime notifyTime, RepeatInterval repeat)
        {
            var intent = CreateIntent(id);

            var localNotification = new LocalNotification();

            localNotification.Title      = title;
            localNotification.Body       = body;
            localNotification.Id         = id;
            localNotification.NotifyTime = notifyTime;
            if (NotificationIconId != 0)
            {
                localNotification.IconId = NotificationIconId;
            }
            else
            {
                localNotification.IconId = Resource.Drawable.plugin_lc_smallicon;
            }

            var serializedNotification = SerializeNotification(localNotification);

            intent.PutExtra(ScheduledAlarmHandler.LocalNotificationKey, serializedNotification);

            var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, intent, PendingIntentFlags.CancelCurrent);
            var triggerTime   = NotifyTimeInMilliseconds(localNotification.NotifyTime);
            var alarmManager  = GetAlarmManager();

            if (repeat == RepeatInterval.No)
            {
                alarmManager.Set(AlarmType.RtcWakeup, triggerTime, pendingIntent);
            }
            else
            {
                long repeateDay = 0;

                switch (repeat)
                {
                case RepeatInterval.Year:
                    repeateDay = 31557600000;
                    break;

                case RepeatInterval.Month:
                    repeateDay = 2629800000;
                    break;

                case RepeatInterval.Day:
                    repeateDay = 86400000;
                    break;

                case RepeatInterval.Hour:
                    repeateDay = 3600000;
                    break;

                case RepeatInterval.Minute:
                    repeateDay = 60000;
                    break;

                case RepeatInterval.Second:
                    repeateDay = 1000;
                    break;
                }

                var totalMilliSeconds = (long)(notifyTime.ToUniversalTime() - _jan1st1970).TotalMilliseconds;
                if (totalMilliSeconds < JavaSystem.CurrentTimeMillis())
                {
                    totalMilliSeconds = totalMilliSeconds + repeateDay;
                }

                alarmManager.SetRepeating(AlarmType.RtcWakeup, totalMilliSeconds, repeateDay, pendingIntent);
            }
        }