LOCAL NOTIFICATION

In Chapter 19, you learn about the Apple Push Notification service (APNs), which enables an application to receive notifications even if it is no longer running on the device. Using the APNs, the provider of an application can continuously keep the user updated, by pushing messages directly to the user through Apple's Push server.

In addition to the APNs, the iPhone also supports another notification framework, local notifications. While the notifications for APNs are sent by the application provider, local notifications are scheduled by the application and delivered by the iOS on the same device. For example, suppose you are writing a to-do list application. At a specific time, your application will display notifications to the user, reminding them of some future tasks. This scenario is a perfect example of the use of local notifications. Another good use of a local notification is that of a location application. The user may be running your application in the background, and when the application detects that the user is in the vicinity of a certain location, it can display a notification.

The following example illustrates the building blocks that you need to have in place in order to create an application that uses local notifications.

TRY IT OUT: Creating Local Notifications

image

  1. Using Xcode, create a new Single View Application (iPhone) project and name it

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.