Notifications are objects that can carry some data and be broadcast to multiple receivers. They are very good for decomposing work into different pieces of code, but can very easily get out of hand if you misuse them. You should understand the limitations of notifications. We will talk more about their uses in this chapter and learn when you are better off without them.
Three types of notifications are available in iOS:
- A normal notification (an instance of
This is a simple notification that your app can broadcast to all possible receivers inside your app. iOS also broadcasts notifications of this type to your app while your app is in the foreground, informing you of various system events that are happening, such as the keyboard showing or being hidden. These notifications are great for decoupling code, in that they can allow you to cleanly separate various components in a complex iOS application.
- A local notification (an instance of
This is a notification that you schedule to be delivered to your app at a specific time. Your app can receive it even if the app is in the background or not running at all, and the app is started if the notification is delivered while your app is not running. You would normally schedule a local notification if you want to ensure that your app gets woken up (granted that the user permits this action, as we will see later) at a specific time of the day.
- Push notifications
This is a notification ...