Introduction:
In this article we are going to how to use the Alarms and Reminders notifications in Windows Phone 7 Application real time. A notification is a message that pops up on the screen to the end users at a specified time scheduled initially. We can make the pop up with some customized message for user friendly requirements. Basically we can make 2 types of notifications an Alarm and a Reminder.
An Alarm is used to play a music file as a notification is launched as scheduled by the end users. A Reminder notification is similar to the Alarm notification expect we can have some text information to show the end user and also we can provide a navigation URI of a page to be opened on clicking of the reminder UI. Also we can include some query strings parameters to pass information that should be used with in the page or the application to which the navigation is pointing to. Microsoft has a limitation of using 50 Alarm or Reminder notifications to be used with in a single application. [more]
Alarm and Reminders uses Alarm Class and Reminder Class respectively, we can see in this article on how to use these classes to create the alarm and reminders that can be used in real time. We will create a new Windows Phone 7 project and provide options to add an alarm and reminder. Let us jump start to see the step by step process on how to do these tasks one by one.
Steps:
First let us create an Alarm application, Open Visual Studio 2010 and create a new application as shown in the screen below.
Now let us add 2 pages, one for adding an alarm content page and other is for adding a reminder content page. Once we added 2 pages in the main page let us add 2 buttons for the user to select to which we can navigate and add the notifications as shown in the screen below.
We have added 2 pages AddAlarm.XAML and AddReminder.XAML, on the button click event we need to navigate to these 2 pages as shown in the code behind.
XAML Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALARM Page:
Now we need to add the content to the AddAlarm.XAML page, here to add an alarm we need to make use of the Alarm class which is inherited from the ScheduledNotification class. Now add the controls to the AddAlarm.XAML Page as shown in the screen below.
XAML Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In the above code we have some properties which are to be considered before we write our requirement on top of it. The properties are as follows
- Name – Unique Name for the Alarm
- Title – This is default name, and we cannot manually set this property
- Content – This property is to set some content for the alarm.
- Begin Time – Beginning of the alarm
- Expiration Time – Expiration time of the alarm
- Recurrence Type – Recurrence type of the alarm
- Sound – Sound file to play for the alarm.
Now we run the application and we can see the alarm configuration as shown in the screen below.
REMINDER Page:
Now let us start with designing the Reminder page, before that we will add a new page called ReminderApp. The use of this page is on reminder trigger we will have option to navigate to a URI with passing some parameter. We will pass values to the pages from the Reminder page, we will see on how to do that with this page. Add contents from the tool box for the Reminder page as shown in the screen below and the code.
XAML Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In the above code we have some properties which are to be considered before we write our requirement on top of the reminder properties. Some of the main properties are as follows
- Name – Unique Name for the Reminder
- Title – This is default name, and we cannot manually set this property
- Content – This property is to set some content for the reminder.
- Begin Time – Beginning of the Reminder
- Expiration Time – Expiration time of the Reminder
- Recurrence Type – Recurrence type of the Reminder
- Navigation URI – On clicking of the application will navigate the user to the new page.
In the above code, if we see we have added a parameter to be passed with the navigation URI as query string. To get the query string value we need to write the below code in the new page (ReminderAppPage.XAML) as shown in the screen below.
C# Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Now we run the application and we can see the Reminder configuration as shown in the screen below.
Conclusion:
So in this article we have seen how to make use of the inbuilt Scheduled Notification mechanism to build applications which notifies to the end users with some custom messages. Alarm and Reminders plays some major role for notifications to the end users as per the requirements.
No Comments
using System.Windows.Controls.Toolkit
in the above code.. toolkit:TimePicker is not working..
i tried installing 7.1.1 update also.. still not working.
is there anyother assembly reference we need to add here ?
plz help.
thank you!
Hello would you mind sharing which blog platform you're using? I'm looking to start my own blog soon but I'm having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I'm looking for something unique. P.S My apologies for getting off-topic but I had to ask!|
Thanks for posting so nice article.we will supports you forever.Thanks.
<a href=http://http://www.iconprotech.com>Plastic Flow Meter</a>
Hi there! This is my first comment here so I just wanted to give a quick shout out and tell you I really enjoy reading through your posts. Can you suggest any other blogs/websites/forums that cover the same subjects? Thanks a lot!|
A fascinating discussion is worth comment. I do believe that you should publish more on this subject matter, it may not be a taboo matter but generally folks don't speak about these topics. To the next! Kind regards!!|
Wow! This blog looks exactly like my old one! It's on a completely different subject but it has pretty much the same page layout and design. Outstanding choice of colors!|
Thank sir very much.