Barcodes with iOS
Bringing together the digital and physical worlds
Oliver Drobnik
  • January 2015
  • ISBN 9781617292156
  • 248 pages
  • printed in black & white

Highly relevant and inspiring.

Jim Matlock, IBM

Barcodes with iOS is the first and only book that comprehensively addresses barcode technology for the iOS developer. It offers an introduction to commonly used formats, such as ISBN and UPC codes, and provides real-world examples that teach you how to integrate code scanning and generation into your apps. This book consolidates information about applicable Apple frameworks in one place so you can quickly add native barcode support to your existing enterprise apps or start building new apps that help bring together the physical and digital worlds.

About the Technology

Barcodes are a universal way to track and share information, appearing on everything from cereal boxes to shop windows. Starting with iOS 7, Apple has added native features for building apps that scan, display, and print barcodes, eliminating the need for third-party libraries.

About the book

Barcodes with iOS teaches you how to effectively use barcodes in your iOS apps. You'll master Apple's new barcode frameworks while you explore real-world examples that integrate code scanning and generation and metadata retrieval into your apps. Along the way, you'll pick up numerous best practices for bringing together the physical and digital worlds.

Table of Contents detailed table of contents



about this book

about the cover illustration

1. Barcodes, iOS, and you

1.1. The evolution of barcodes

1.1.1. One dimension: laser

1.1.2. Two dimensions: CCD

1.1.3. Versatility is winning

1.1.4. Where are the bars?

1.2. Barcode symbologies in iOS

1.2.1. 1D barcodes in iOS

1.2.2. 2D barcodes in iOS

1.2.3. So many choices: which barcode should I use?

1.3. Summary

2. Media capture with AV Foundation

2.1. Introducing AV Foundation

2.2. Building a camera app

2.2.1. AV Foundation setup

2.2.2. Building the camera UI

2.2.3. Selecting capture devices

2.2.4. Media capture session

2.2.5. Showing live video preview

2.2.6. Authorizing camera access (or not)

2.2.7. Toggling the video light

2.2.8. Taking pictures to the camera roll

2.2.9. Supporting rotation of device and UI

2.2.10. Switching between camera devices

2.2.11. Implementing autofocus and tap-to-focus

2.3. Summary

3. Scanning barcodes

3.1. Metadata detection in AV Foundation

3.2. Building a QR Code scanner

3.2.1. Reusing camera code

3.2.2. Creating and configuring the metadata output

3.2.3. Wiring up the metadata objects' delegate

3.2.4. Creating a barcode scan delegate

3.2.5. Marking detected barcodes on preview

3.2.6. Building an optimal scanning UI

3.2.7. Tweaking capture device settings

3.2.8. Opening a scanned web address in Mobile Safari

3.3. Summary

4. Passbook, Apple’s digital wallet

4.1. Barcodes in Passbook

4.2. Producing digital passes for your users

4.2.1. Requesting a certificate for signing passes

4.2.2. Preparing signing certificates

4.2.3. Constructing passes

4.2.4. Pass creation takeaways

4.3. Validating passes

4.3.1. Building a ticket-verifier app

4.3.2. Reusing barcode scanner code

4.3.3. Serverless pass validation

4.3.4. Pass validation takeaways

4.4. Summary

5. Generating barcodes

5.1. Producing barcodes for display or print

5.1.1. Thoughts on barcode size

5.1.2. QR Code error correction

5.2. Generating 2D barcodes

5.2.1. Building a QR Code Builder app

5.2.2. Introducing Core Image

5.2.3. Project setup for Core Image

5.2.4. Generating QR Codes with Core Image

5.2.5. Copying the QR Code to the pasteboard

5.2.6. Private APIs for Aztec and PDF417 codes

5.2.7. Printing barcodes with AirPrint

5.2.8. Saving trees with the iOS Printer Simulator

5.2.9. Custom drawing with UIPrintPageRenderer

5.2.10. AirPrint paper selection

5.2.11. QR Code Builder app summary

5.3. Generating 1D barcodes

5.3.1. Building a Serial Number Tag app

5.3.2. Introducing BarCodeKit

5.3.3. Adding BarCodeKit to your project

5.3.4. Setting up the Serial Number Tag app’s UI

5.3.5. Generating 1D barcodes with BarCodeKit

5.3.6. AirPrint and roll-feed printers

5.3.7. Serial Number Tag app summary

5.4. Summary

6. Getting metadata for barcodes

6.1. Modern networking with NSURLSession

6.1.1. File downloads with NSURLSessionDownloadTask

6.1.2. Building a Music Collection app

6.1.3. Asynchronous Core Data updates

6.1.4. Presenting the barcode scanner modally

6.1.5. Using NSURLSessionDataTask to call RESTful web APIs

6.1.6. Authenticating API requests with OAuth

6.1.7. Adding DTOAuth to your project

6.1.8. Configuring the OAuth consumer

6.1.9. Implementing the UI for OAuth authorization

6.1.10. Connecting barcode scanning and metadata retrieval

6.2. Unit-testing network operations

6.2.1. Introducing NSURLProtocol

6.2.2. Implementing a custom URL scheme with NSURLProtocol

6.2.3. Stubbing NSURLRequest responses with DTURLProtocolStub

6.2.4. Stubbing NSURLSession requests with DTURLProtocolStub

6.2.5. How to test asynchronous completion handlers

6.2.6. Shifting to test-driven development

6.3. Summary

7. Putting barcodes in context

7.1. Understanding multiple layers of context

7.2. Building a YardSale app

7.2.1. Creating the outside-the-store experience

7.2.2. Implementing the in-store user interface

7.3. Geofencing store locations

7.3.1. Introducing region monitoring

7.3.2. Monitoring an unlimited number of regions

7.3.3. Updating monitored regions based on user location

7.3.4. Notifying users when entering a monitored region

7.4. Enhancing the in-store UI with iBeacons

7.4.1. Introducing the iBeacon system

7.4.2. iBeacon monitoring at a glance

7.4.3. Making any app emit an iBeacon

7.4.4. Determining distance to iBeacons with ranging

7.4.5. Adding an in-store barcode scanner

7.5. Summary

Appendix A: History of the UPC

A.1. Bull’s-eye origins

A.2. Startup story

A.3. UPC plus EAN equals GTIN

A.4. Barcodes in the mobile age

A.5. Summary

Appendix B: GTIN prefix ranges

Appendix C: GS1-128 application identifiers


What's inside

  • Learn about all barcode formats supported by iOS
  • Native barcode scanning with AV Foundation
  • Using Core Image and BarCodeKit to produce a wide range of barcodes
  • Printing to sheets and labels with AirPrint
  • Retrieving metadata for products with NSURLSession and NSURLProtocol
  • Harnessing context information from Core Location and iBeacons

About the reader

This book is written for readers with a working knowledge of Objective-C and iOS app development.

About the author

Oliver Drobnik is an independent consultant specializing in custom iOS and Mac development.

placing your order...

Don't refresh or navigate away from the page.
print book $23.99 $39.99 pBook + eBook + liveBook
Additional shipping charges may apply
Barcodes with iOS (print book) added to cart
continue shopping
go to cart

eBook $25.59 $31.99 3 formats + liveBook
Barcodes with iOS (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.
customers also reading

This book 1-hop 2-hops 3-hops

FREE domestic shipping on three or more pBooks