0
INDEPTH LOOK AT LOCAL AND REMOTE NOTIFICATIONS
The importance of both local and remote
notifications is to enable an app to inform its users that it has an
information for them – take for example, a message or a missed event—when the
app isn’t running in the foreground.
Users
can get notified in the following ways:
·      
An onscreen alert or banner
·      
A badge on the app’s icon
·      
A sound that comes as an alert, badge or
banner
Application icon with a badge number:
The user hears the sound & sees the
badge and then responds by launching the app to see the to-do item. Users can control
how the device and specific apps installed on the device should handle
notifications. They can also enable or disable remote notification types (i.e
icon badging, alert messages, and sounds) for specific applications.
LOCAL
NOTIFICATIONS
Local notifications are ideally suited
for apps with time-based behaviors, such as calendar and to-do list apps. Apps
that run in the background for the limited period allowed by iOS might also
find local notifications useful. For example, apps that depend on servers for
messages or data can poll their servers for incoming items while running in the
background; if a message is ready to view or an update is ready to download,
they can handle the data as needed, and notify users if appropriate.
A local notification is an instance of
UILocalNotification or NSUserNotification with three general kinds of
properties:
Scheduled time. You must specify the
date and time the operating system delivers the notification; this is known as
the fire date. You can qualify the fire date with a specific time zone so that
the system can make adjustments to the fire date when the user travels. You can
also request the operating system to reschedule the notification at a regular
interval (weekly, monthly, and so on).
Notification type. These properties
include the alert message, the title of the default action button, the app icon
badge number, a sound to play, and optionally in iOS 8 and later, a category of
custom actions.
Each app on a device is limited to 64
scheduled local notifications. The system discards scheduled notifications in
excess of this limit, keeping only the 64 notifications that will fire the
soonest. Recurring notifications are treated as a single notification.
REMOTE
NOTIFICATIONS
An iOS or Mac app is often a part of a
larger application based on the client/server model. The client side of the app
is installed on the device or computer; the server side of the app has the main
function of providing data to its client apps, and hence is termed a provider.
A client app periodically connects with its provider and downloads any data
that is waiting for it. Email and social-networking apps are examples of this
client/server model.
But what if the app is not connected to
its provider or even running on the device or computer when the provider has
new data for it to download? How does it learn about this waiting data? Remote
(or push) notifications are the solution to this dilemma. A remote notification
is a short message that a provider has delivered to the operating system of a
device or computer; the operating system, in turn, can inform the user of a
client app that there is data to be downloaded, a message to be viewed, and so
on. If the user enables this feature (on iOS) and the app is properly
registered, the notification is delivered to the operating system and possibly
to the app. Apple Push Notification service (APNs) is the primary technology
for the remote-notification feature.
Remote notifications serve much the same
purpose as a background app on a desktop system, but without the additional
overhead. For an app that is not currently running – or, in the case of iOS,
not running in the foreground – the notification occurs indirectly. The
operating system receives a remote notification on behalf of the app and alerts
the user. Once alerted, users may choose to launch the app, which then
downloads the data from its provider. If an app is running when a notification
comes in, the app can choose to handle the notification directly.
As its name suggests, Apple Push
Notification service uses a remote design to deliver remote notifications to
devices and computers. A push design differs from its opposite, a pull design,
in that the recipient of the notification passively listens for updates rather
than actively polling for them. A push design makes possible a wide and timely
dissemination of information with few of the scalability problems inherent with
pull designs. APNs uses a persistent IP connection for implementing remote
notifications.
When a device is not online, APNs
retains the last notification it receives from a provider for an app on that
device. If the device then comes online, APNs pushes the stored notification to
it. A device running iOS receives remote notifications over both Wi-Fi and
cellular connections; a computer running OS X receives remote notifications
over both Wi-Fi and Ethernet connections.
Note:
In iOS, remote notifications use Wi-Fi if it is turned on and connected. If
Wi-Fi connection fails, remote notifications attempt to use the device’s
cellular connection.
For some devices to receive
notifications via Wi-Fi, the device’s display must be on (that is, it cannot be
sleeping) or it must be plugged in. iPad remains associated with its Wi-Fi
access point while asleep, permitting the delivery of remote notifications. The
iPad Wi-Fi radio wakes the host processor for incoming traffic as needed.
Sending notifications too frequently
negatively impacts device battery life because a device must access the network
to receive a notification.
Adding the remote-notification feature
to your app requires that you obtain the proper certificate from Member Center
and then write the requisite code for the client and provider sides of the app.
Provisioning and Development explains the provisioning and setup steps, and
APNs Provider API and Registering, Scheduling, and Handling User Notifications
describe the details of implementation.
The Difference Between Local Notifications And
Remote Notifications
:
Local notifications are scheduled by an
app and delivered on the same device.
Remote notifications, also known as push
notifications, are sent by your server to the Apple Push Notification service,
which pushes the notification to devices.
Local and Remote Notifications Appear
the Same to Users

Post a Comment

 
Top