/// <summary>
        /// Executed if one of the Intents is received defined by the IntentFilter.
        /// <seealso cref="BroadcastReceiver.OnReceive(Context, Intent)"/>
        /// <seealso cref="IntentFilter"/>
        /// </summary>
        /// <param name="context">the received Context</param>
        /// <param name="intent">the received Intent</param>
        public override void OnReceive(Context context, Intent intent)
        {
            XMLAccess <List <Appointment> > xmlAccess = new XMLAccess <List <Appointment> >("Appointments");
            IEnumerable <Appointment>       appointmentsWithOpenNotifications = xmlAccess.Load().Where(appointment => appointment.AppointmentReminder && !appointment.AppointmentDone);

            NotificationEventReceiver.UpdateAlarms(context, appointmentsWithOpenNotifications);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a notification on the smartphone for a given appointment.
        /// </summary>
        /// <param name="appointment">the appointment which needs a notification</param>
        private void CreateNotification(Appointment appointment)
        {
            var ci = SmaNa.ViewModel.ViewModelSettings.SmaNaSettings.Language;

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
            builder.SetContentTitle(appointment.PushMessageHeader)
            .SetAutoCancel(true)
            .SetContentText("")
            .SetSmallIcon(Resource.Drawable.logo);

            Intent mainIntent    = new Intent(this, typeof(NotificationActivity));
            string appointmentID = appointment.AppointmentID.ToString();

            mainIntent.PutExtra("AppointmentID", appointmentID);
            PendingIntent pendingIntent = PendingIntent.GetActivity(this,
                                                                    NOTIFICATION_ID,
                                                                    mainIntent,
                                                                    PendingIntentFlags.UpdateCurrent);

            builder.SetContentIntent(pendingIntent);
            builder.SetDeleteIntent(NotificationEventReceiver.GetDeleteIntent(this));

            NotificationManager manager = (NotificationManager)GetSystemService(NotificationService);

            manager.Notify(NOTIFICATION_ID, builder.Build());
            NOTIFICATION_ID++;
        }