Barcodes with iOS
eBook - ePub

Barcodes with iOS

Bringing together the digital and physical worlds

Oliver Drobnik

Share book
  1. 248 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Barcodes with iOS

Bringing together the digital and physical worlds

Oliver Drobnik

Book details
Book preview
Table of contents
Citations

About This Book

Summary 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.Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. 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.This book is written for readers with a working knowledge of Objective-C and iOS app development. 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 Author Oliver Drobnik is an independent consultant specializing in custom iOS and Mac development. Table of Contents

  • Barcodes, iOS, and you 1
  • Media capture with AV Foundation 18
  • Scanning barcodes 48
  • Passbook, Apple's digital wallet 70
  • Generating barcodes 97
  • Getting metadata for barcodes 133
  • Putting barcodes in context 172

  • Appendices
  • History of the UPC 205
  • GTIN prefix ranges 212
  • GS1-128 application identifiers 217

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Barcodes with iOS an online PDF/ePUB?
Yes, you can access Barcodes with iOS by Oliver Drobnik in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation d'appareils mobiles. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Manning
Year
2015
ISBN
9781638353270

Chapter 1. Barcodes, iOS, and you

This chapter covers
  • Why the nexus of barcodes and mobile technologies is creating new, exciting opportunities for app makers
  • The barcode symbologies in iOS you should know about
  • The distinctions between 1D and 2D barcodes
  • A brief history of the UPC/GTIN, the mother of modern barcodes
In the past, if you wanted to add barcode scanning to your apps, you had to either fight your way through open source projects or license a commercial barcode-scanning library. None of those projects were written in Objective-C, documentation was lacking, and commercial solutions required payment of license fees for each downloaded copy of your app. All of these issues made barcode scanning impractical for all but the most skilled iOS developers, and too expensive to make economic sense for free or low-cost apps.
When Apple added Passbook to iOS 6, they built in the ability to display barcodes on Passbook passes. With iOS 7, Apple made these APIs public and added the ability to scan barcodes. This allowed them to add barcode-scanning functionality to several of their first-party apps:
  • The Passbook app lets you add new passes to your device by scanning special QR Codes.
  • The iTunes app has the ability to redeem iTunes credits by scanning a voucher.
  • The Apple Store app has an in-store UI that lets you scan the barcodes of accessories for unassisted checkout (see figure 1.1).
    Figure 1.1. Barcode scanning in the Apple Store app
In June 2014, the mother of all barcodes, the UPC, celebrated its 40th anniversary. This makes it an incredibly well understood and ubiquitous technology. Throughout these four decades, different usage scenarios prompted the development of a variety of barcode symbologies that were more or less all informed by the UPC. Apple selected from these the most prevalent and useful kinds of barcodes to support in iOS 7. Support for a few additional barcode symbologies was added in iOS 8. To grasp the full potential of these differing symbologies—as they’re relevant to you in iOS app development—you’ll learn which purposes they’re best used for.
This introductory chapter will give you a solid understanding of barcode technology. Seeing how the multitude of symbologies relate to each other should alleviate any anxiety you might feel right now. You’ll no longer shiver in fear from not knowing the difference between UPC, EAN, GTIN, Code 25, Code 39, Code 93, and Code 128. A brief history of the UPC/GTIN will prove illuminating. Not only has its long history been quite amusing at times, this background will aid greatly in your appreciation of the current state of the GTIN. You’ll become a barcode guru and be able to hold your own in any discussion about barcodes.
In order to appreciate the power of the barcode, we’ll first take a look at how they evolved. Beginning with the UPC, more and more barcode symbologies evolved over time because their predecessors had been designed to solve very specific problems. If you know how to tell them apart—just from glancing at them—you’ll know if you’re looking at an opportunity for a new app.

1.1. The evolution of barcodes

The first barcode in wide use was the Universal Product Code (UPC), combining the semantic meaning of a 12-digit number with a machine-readable scheme for representing this number as a series of bars. It was designed only for automated handling of physical products and was therefore limited to representing numerical product codes. Appendix A will walk you through the history of the UPC and how it became the GTIN, as it’s referred to nowadays by people in the know. Figures 1.2a and 1.2b show some examples of how barcodes have changed over the years.
Figure 1.2a. Timeline of barcodes
Figure 1.2b. Timeline of barcodes
Having overcome the hurdle of enabling a machine to recognize visual markings with a laser beam, a plethora of other kinds of barcodes started to appear, all with more-or-less specific fields of application. For example, the post office found that adding markings to mailed items would allow them to automatically sort the items. Luggage for airline travel was similarly tracked with numeric codes. Other industries had their own standards that worked better for them.
A combination of several bars that make up an individual character or digit is often called a symbol. The set of symbols available for a specific barcode standard is referred to as its symbology. All these different symbologies can be read with a laser beam.

1.1.1. One dimension: laser

Think of a laser beam as cutting out a horizontal slice of the vertical code bars. As the beam moves over the symbol (see figure 1.3), it measures the relative time it spends scanning dark bars and light spaces. A lookup table is then used to decode individual characters from those times.
Figure 1.3. A laser needs to cross all bars of a 1D barcode for scanning
The line of the laser beam is also the reason why these kinds of barcodes are referred to as being one-dimensional (1D).
If you have more-complex encoding schemes, you can also represent letters and special characters. Some 1D barcode types were created to represent short texts.
The long-recognized major advantage of 1D barcodes is that they can be decoded extremely reliably even when the items tagged with such codes are moving at high speed. Some schemes even employ checksums to recognize when something is misread and increase this reliability.
The second advantage of 1D barcodes is cost. Because the technology has been around for 40 years now, the necessary components (laser diode and decoding electronics) have become cheap and reliable. This makes them ideally suited for high-volume deployment as well as for use in environments where you need to scan a great many codes in quick succession.

1.1.2. Two dimensions: CCD

The charge-coupled device (CCD) was invented at AT&T Bell Labs by Willard Boyle and George E. Smith in 1969. This is the chip at the heart of any kind of digital camera. Curiously, the technology for CCDs was invented around the time the first 1D barcode was introduced, but it took decades to develop CCDs to the point where they could compete with the accuracy of their technically much simpler predecessors.
A CCD is essentially a matrix of pixels that reads different binary values for each pixel depending on the light intensity shining on it. As a result, a CCD can read barcodes just like a laser beam can if you have a sufficient number of pixels (a.k.a. resolution). Because the CCD pixels are laid out in two dimensions, CCDs are also able to recognize a new kind of barcode, the two-dimensional (2D) barcode.
Freed of the limitations of one dimension, 2D barcodes usually consist of small rectangles laid out to form a square grid. Figure 1.4 shows such a barcode.
Figure 1.4. A CCD camera can “see” the squares that make up a 2D b...

Table of contents