Chapter 13. Integrating push notifications

 

This chapter covers

  • Apple’s Push Notification service
  • Configuring your app to send and receive push notifications
  • Sending remote push notifications
  • Registering and scheduling local notifications

In iOS, applications are not allowed to perform continuous operations in the background. But what if something interesting does happen and you want to let your users know about that even if the app is closed? Say you create an application for sending short messages to other people. Chances are the user is not using your application when a friend asks him to have some margaritas by the beach.

Push notifications are the solution for these issues; they’re a great way for apps to interact with users at any time. When an event of interest occurs, you send a specially crafted message to a user’s device, and they’ll see a message and hear an alert. This is similar to what happens when you get an SMS or a new email on your iPhone.

In this chapter you’ll learn how push notifications take place. You’ll learn how to configure your app to accept push notifications and how to send them. At the end of the chapter you’ll have the tools to interact with your users, even when they aren’t using your application. You’ll create a simple application called SaleAlerts, which alerts the user to new offers using push notifications, as shown in figure 13.1.

Figure 13.1. Push notification coming to our SaleAlerts application while the app is closed

13.1. Apple’s Push Notification service

13.2. Configuring your app to send and receive push notifications

13.3. Sending push notifications

13.4. Registering and scheduling local notifications

13.5. Summary