Introduction

Alarms and reminders are some of the various Windows Phone scheduled notification options that every developer can take advantage of to make his app more responsive and useful. They inherit from ScheduledNotfication and the ScheduledActionService class. In this tutorial we will get to know what an alarm is, what a reminder is and what the differences are between an alarm and the reminder. 

  1. Alarms:This is how the alarm looks like in Windows Phone.

alarm result

 

Properties:

At a specified time, the alarm dialog box pops up. It consists of: 

  • The app name: the name of the app from which the alarm was created.
  • “Alarm” is always set as a title.
  • Content: set by the app or the user.
  • You can manage the alarm sound from the app.

If the user clicks on snooze the phone will launch automatically the alarm again after 9 minutes. 

However if he clicks on the alarm’s UI, the app that created the alarm will be launched at it’s initial page.

   2.  Reminders:

reminder result

 

Properties:

  • Reminders use the default reminder sound (of the device).
  • You can edit both the title and the content.
  • Once the user clicks on the reminder’s UI it’ll open the app or a specific page within the app. 

How to add an alarm / a reminder ?

In order to implement alarms and reminders in your project create a new Windows Phone 8 Silverlight Project named “Alarms and Reminders”.

Download Windows Phone Toolkit: 

If we want to make our app really useful, then we’d better user some controls that will make the app more practical and user friendly. That’s why we’re going to use the DatePicker and TimePicker controls, which are included in the Windows Phone toolkit. To do so let’s first download the Windows Phone toolkit. In the tools menu click on NuGet Package Manager and Package Manager console. 

How to download WP toolkit

After some moments the console will appear, write the following command : 

NuGetConsole

And Visual Studio will download the Windows Phone toolkit for you.

Adding Windows Phone Toolkit:

Now let’s add our controls! In the MainPage.xaml add the following xaml code at the top of the page but below the <phone:PhoneApplicationPage statement:  

Now we can use the DatePicker and TimePicker controls. 

So we are going to ask the user about the date and time of the notification and we will let him choose whether to use an alarm or a reminder: try to use stackpanels, textblocks , buttons, date and time pickers to make the following UI. First let’s add our textblocks to a stackpanel that has a vertical orientation also add two buttons in a stackpanel with a horizontal orientation.Then we will put both of the stackpanels in a container stackpanel.

Application's UI

Then we’ll add the Date and Time picker controls.

To add a DatePicker control copy and paste the following line of code :

And this one for the TimePicker: 

Knowing that if we don’t use a TimePicker, the phone will set it automatically to 00.00.

After we are done with making a suitable user interface, we’ll add both the alarm and the reminder using the click event handler of the addReminderButton button and the addAlarmButton button.

How to add reminders and alarms using C# code ?

In the Code behind MainPage.xaml(MainPage.xaml.cs file) add this using statement which will let us work with the ScheduledNotificationClass 

In the Constructor, declare two variables named alarm and reminder of type Alarm and Reminder. 

Adding alarms:

In the clicked event handler of the add alarm button add the following block of code

 

 As for the addReminderButton click event, add the same code that we wrote for alarm but just replace the alarm variable with the reminder variable!

Note that you can use the reminder properties to set a title and a navigation Uri if wanted! 

Results:

alarm result               reminder result

Conclusion:

In this tutorial we learned how to download the Windows Phone toolkit, how to add it to our project and how to use 2 of its controls, the DatePicker and TimePicker, as well. We also used those controls to make a small alarm and reminder app which enables the user to set a date and a time for a wanted alarm or reminder. You can download the project sample Here