IT tutorials
 
Technology
 

Windows Phone 8 : Phone Integration - Alarms and Reminders

8/8/2013 11:25:20 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

When you’re creating your application, you might need the ability to alert the user about specific notifications. Windows Phone supports this by enabling you to create two types of notifications: alarms and reminders.

Alarms are notifications that show a message and allow the user to tap the alarm to start your application. Additionally, the user can snooze the alarm or dismiss it. With an alarm, you can also specify a custom sound located in your application to use as the alarm sound. You can see an alarm in action in Figure 1.

Image

FIGURE 1 An alarm

Reminders are similar to alarms, but they have additional functionality:

You can specify the title of a reminder (which is always “Alarm” for alarms).

The user can specify how long to snooze a reminder.

You can decide to send contextual information when the user taps a reminder (whereas the alarm can simply launch the application).

You cannot specify a specialized sound for reminders.

Figure 2 shows a reminder. If alarms or reminders are not closed when additional notifications appear, they will be stacked with an identifier that mentions how many notifications need to be handled, as shown in Figure 3.

Image

FIGURE 2 A reminder

Image

FIGURE 3 Stacked notifications

Alarms and reminders are both tied to your application. They are notifications for your application. If you want to allow users to disable/enable these notifications, you must supply that functionality in your application. There is no operating system-level management UI for these notifications.


Tip

The precision of alarm and reminder times is to the minute. If you create notifications that need higher precision, the service that handles alarms and reminders will not show the notification more than after per minute. Be prepared for the alarms that are within a minute of a notification to be stacked.


Now that you’ve seen how notifications look, let’s discuss how you actually create your own notifications.

Creating an Alarm

To create a new alarm, you can simply create a new Alarm object and instantiate all the relevant properties, like so:

// Create Alarm - name must be unique per app
var alarmName = Guid.NewGuid().ToString();

var alarm = new Alarm(alarmName)
{
  // When the Alarm should sound
  BeginTime = DateTime.Parse("2011-12-25T06:30"),

  // The Message in the Alarm
  Content = "Wake Up for Christmas!",

  // What sound to play for the alarm
  Sound = new Uri("santa.wav", UriKind.Relative)
};

// Add the Alarm to the Phone
ScheduledActionService.Add(alarm);

Each alarm must have a name that is unique to your application (that is, names do not need to be globally unique). So, it is common to just use a GUID to name your alarm. This name is not visible to the user. After you construct the alarm using the unique name, you would typically specify several key properties, including the following:

BeginTime: This is the time the alarm will alert the user.

Content: This is the text to be shown in the alarm beneath the “Alarm” title.

Sound: This is a URI to the sound in your .xap file that should be used to play when the alarm occurs.

Finally, you will use the ScheduledActionService to add the alarm to the phone. This service is the starting point for both alarms and reminders (as they are both considered a ScheduledAction). You can simply add your alarm to the phone by using the service class as shown in the example.

You can also create alarms to have recurrence. To do this, you should set both the RecurrenceType and the ExpirationTime. The RecurrenceType is an enumeration that enables you to specify whether the alarm is hourly, daily, weekly, and so forth. The ExpirationTime specifies how long to repeat the recurrence:

// ...
// Set Recurrence
alarm.RecurrenceType = RecurrenceInterval.Yearly;
alarm.ExpirationTime = DateTime.Today.AddYears(10);

// ...

The Alarm class has a Title property that looks like you can set the title of your alarm, but this is not supported (that is, it throws a NotSupportedException). The title of all alarms is “Alarm.”

Creating a Reminder

Because alarms and reminders both derive from ScheduledAction, you can correctly assume that creating a reminder is similar to creating an alarm:

// Create Reminder - name must be unique per app
var reminderName = Guid.NewGuid().ToString();

var reminder = new Reminder(reminderName)
{
  // Reminder Time
  BeginTime = DateTime.Today.AddHours(6),

  // Title for the Reminder
  Title = "Wake Up Reminder",

  // The description below the Title
  Content = "You should get up now...",

  // The page to navigate to (and any other context)
  // when the user taps the reminder
  NavigationUri =
    new Uri("/MainPage.xaml?wake=true", UriKind.Relative),
};

// Add the reminder
ScheduledActionService.Add(reminder);

However, creating a reminder is different from creating an alarm, in several ways. First, the Title property is supported, so you can specify what the title is on your reminder. Unfortunately, unlike the alarm, the Sound property is missing, so reminders can only have the sound that the system defines as the reminder sound (although the user can set that in the phone’s Options section).

The biggest difference between an alarm and a reminder is that you can specify the NavigationUri to specify the deep linking of the reminder to a specific page (with context). The NavigationUri allows you to specify a relative URL of the page to show in your applications as well as an optional query string to include context to the reminder. If the user taps on the reminder, it will open your app and navigate to the URI you’ve specified.

Accessing Existing Notifications

After you’ve added notifications to the phone, you might want to support managing those notifications. The ScheduledActionService class has several members that can help you manage your notifications:

Add: This adds a new notification to the phone.

Find: This locates a notification by name.

GetActions<T>: This returns a read-only collection of notifications based on the type (alarm or reminder).

Remove: This removes a specifically named notification from the phone.

Replace: This replaces a named notification with a new notification (of the same name).

For example, to get a list of reminders and bind them to a list box, you can simply use the GetActions method:

// Returns an IEnumerable<Reminder> object
var reminders = ScheduledActionService.GetActions<Reminder>();

// A ListBox named 'theBox'
theBox.ItemsSource = reminders;

The base class for the notifications (ScheduledAction) supports a read-only property called IsScheduled, which is used to tell you whether the alarm or reminder is still scheduled to show a notification in the future. Although the class supports the IsEnabled property, it is always true for alarms and reminders.

 
Others
 
- Windows Phone 8 : Phone Integration - Contacts and Appointments
- Active Directory 2008 : Supporting User Objects and Accounts (part 3) - Administering User Accounts
- Active Directory 2008 : Supporting User Objects and Accounts (part 2) - Managing User Attributes with DSMod and DSGet, Understanding Name and Account Attributes
- Active Directory 2008 : Supporting User Objects and Accounts (part 1) - Managing User Attributes with Active Directory Users And Computers
- Exchange Server 2010 Administration Essentials : Using and Managing Exchange Server Services
- Exchange Server 2010 Administration Essentials : Understanding Data Storage in Exchange Server 2010
- Windows 8 Tile-Based Apps : Calendar
- Windows 8 Tile-Based Apps : Cloud Service Connections
- Windows 8 Tile-Based Apps : People
- Introduction to Sharepoint 2013 : SHAREPOINT CENTRAL ADMINISTRATION
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us