Chapter 18. Sharing and Notifications

Just about every app these days deals with some kind of content—whether it’s business documents written in an office suite, images created in an image editor, or even high scores earned in a game. Users frequently want to be able to show this content to other people, and the OS provides built-in sharing APIs that let your application send various kinds of content to services that can handle them. For example, online services like YouTube and Vimeo can receive video files and share them over the Internet, the Messages app can send text, photos, and videos, and email can send just about any file.

In addition to sending content to other locations, the OS is also capable of receiving notifications. These are short messages sent from a server to an iOS device, which are received regardless of whether the app is running or the phone is awake.

In this chapter, you’ll learn how to share data from your application using the built-in sharing APIs, and how to send and receive both push and local notifications.

Sharing

From the user’s perspective, the problem of data sharing can be rephrased as, “How can I send this to someone else?” From your application’s perspective, however, the problem of data sharing is really the question, “Where can I send this data?”

Different systems are capable of accepting different kinds of data. A video, for example, cannot be sent to a printer, and plain text cannot be sent to a photo-hosting site like Flickr. Fortunately, the ...

Get Swift Development with Cocoa now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.