O'Reilly logo

iOS 7 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.7. Setting Up Your App for Push Notifications

Problem

You want to configure your application so that you can push notifications from a server to various devices.

Solution

Follow these steps:

  1. Set up a provision profile for your app with push notifications enabled.

  2. In your app, register the device for push notifications for your app.

  3. Collect the device’s push notifications identifier for your app and send that to a server.

Note

In this recipe, we are going to discuss setting up and registering your app for push notifications. We are not going to talk about the server side of things yet. We will discuss that part in another recipe.

Discussion

Push notifications are similar to local notification in that they allow you to communicate something with the user even when your app is not running. Although local notifications are scheduled by your app, push notifications are configured and sent by a server to Apple, and Apple will push the notifications to various devices around the world. The server part of things needs to be done by us. We then compose the push notifications and send them to Apple Push Notification Services servers (or APNS, as it is known). APNS will then attempt to deliver our push notifications through a secure channel to devices that we designated the push notifications to be delivered to.

For iOS apps to be able to receive push notifications, they have to have a valid provision profile that has push notifications enabled. To configure your profile properly, follow these steps: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required