Learning iBeacon

Book description

Build proximity applications for iOS using Apple's groundbreaking iBeacon technology

In Detail

Starting with an introduction to iBeacon, you will learn all about simple beacon detection. You will learn how to use Apple's CoreBluetooth, CoreLocation, and PassKit libraries, and how to broadcast different values through the power of transmission power.

You will learn how to allow your apps to detect beacons, determine their distance, and even turn your iPhone or iPad into a Bluetooth iBeacon by building a simple treasure-hunting app. We will also be discussing two of the most popular beacons (Estimote and ROXIMITY). Don't worry if you haven't got any beacons; this book includes a companion app that lets your Mac or MacBook act as a beacon to allow you to jump straight into learning this incredible technology.

By the end of this book, you will have learned how to build apps that interact with the world around them using Bluetooth beacons.

What You Will Learn

  • Detect beacons in range and read the values they broadcast
  • Understand beacon regions and use Core Location framework to determine when you enter or exit a beacon region
  • Use beacon broadcast values to identify the beacon and determine the purpose of it
  • Utilize the CoreBluetooth library to turn your iOS device into an iBeacon
  • Build a functionality that understands the world around it within a few inches by determining beacon distance
  • Notify users that they've entered a region while the app's running in the background and use beacons to show Apple Passbook passes when in range
  • Build a comprehensive museum app that informs the visitor about the exhibits that they're closest to as they walk around the museum
  • Understand Bluetooth low energy and the technology behind iBeacon

Table of contents

  1. Learning iBeacon
    1. Table of Contents
    2. Learning iBeacon
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Welcome to iBeacon
      1. Introducing iBeacon
      2. Hey, 'sup
      3. Understanding a range using RSSI
      4. Compatible devices
      5. Commercial applications of iBeacon
      6. So many vendors, so little time
        1. Estimote
          1. Estimote beacons – pros
          2. Estimote beacons – cons
        2. ROXIMITY
          1. ROXIMITY beacons – pros
          2. ROXIMITY beacons – cons
        3. RedBearLab
          1. RedBear Beacon B1 – pros
          2. RedBear Beacon B1 – cons
        4. Other vendor options
      7. The companion OS X application and website
        1. Using the companion app
      8. Hello world
        1. Let's get started
        2. Adding the Core Location framework
        3. Adding a permission message
        4. Configuring the CLLocationManagerDelegate method
        5. Adding a CLLocationManager instance
        6. Preparing UUID
        7. Start monitoring
          1. Line by line
      9. Testing our code
      10. Summary
    9. 2. Detecting Beacons – Showing an Advert
      1. Uses of the UUID/major/minor broadcasting triplet
        1. UUID – Universally Unique Identifier
        2. Major
        3. Minor
        4. An example of a use case
      2. Understanding Core Location
        1. The CLBeaconRegion class
        2. The CLLocationManager class
      3. Creating a CLLocationManager class
        1. Defining a CLLocationManager class line by line
        2. locationManager:didEnterRegion
        3. locationManager:didExitRegion
        4. locationManager:didRangeBeacons:inRegion
        5. locationManager:didChangeAuthorizationStatus
      4. Understanding iBeacon permissions
        1. Location permissions in iOS 8
        2. Enabling the location after denying it
      5. Building the tutorial app
        1. Creating the app
        2. Adding CLOfferViewController
        3. Setting location permission settings
          1. Adding some controls
          2. Setting up our root view controller
          3. Configuring our location manager
          4. Wiring up CLLocationManagerDelegate
          5. Showing the advert
          6. Dismissing the offer
      6. Summary
    10. 3. Broadcasting Advertisements – Sending Offers
      1. Introducing the Core Bluetooth framework
        1. Understanding centrals and peripherals
        2. The Core Bluetooth framework, centrals, and peripherals
          1. The CBCentral class
          2. The CBPeripheral class
          3. The CBPeripheralManager class
      2. Obtaining broadcast values from CLBeaconRegion
        1. Measured power (TXPower)
        2. Let's get started
          1. Adding frameworks
          2. Setting up our controls
          3. Creating our views
          4. Wiring up the storyboard
          5. Setting up our view controller
          6. Adding our switch logic
      3. Summary
    11. 4. Ranging Beacons – Hunting for Treasure
      1. There be treasure nearby
      2. Understanding distance
      3. Our application
      4. Getting started with building our app
        1. Drawing our initial views
        2. Adding frameworks and project settings
        3. Adding images
        4. Building the root view controller
        5. Building the treasure view controller
          1. Finally, wire it up
        6. Building the hunter view controller
          1. Hunter view controller states
          2. Imports and public properties
          3. Private properties
          4. Loading the view
          5. Entering and exiting the region
          6. Changing the state
          7. Tidying up
          8. Being extra conscientious
      5. Completing the code
      6. Summary
    12. 5. Detecting Beacons in the Background – Location Dating
      1. Real-life use cases
        1. An example use case for retail loyalty
        2. An example use case for airline assistance
      2. Handing over responsibility
      3. The CLBeaconRegion options
      4. Passbook integration
      5. Our tutorial app
        1. The scenario
        2. Viewing anatomy
        3. The code
          1. Creating the application
          2. Creating the view
          3. Configuring the app delegate
            1. No ranging in the background
            2. Entering and exiting regions
            3. Clearing out badges
            4. Ranging beacons
          4. Implementing our view controller
            1. Initializing the view
            2. Receiving beacon distance
            3. Choosing a gender
            4. Adding a passbook pass
      6. Testing your application
        1. Testing the beacons
        2. Testing the passbook pass
      7. Summary
    13. 6. Leaving Regions – Don't Forget Your Stuff
      1. Raspberry Pi
      2. Ninja Blocks
      3. Nest
      4. Phillips Hue
      5. Belkin WeMo
      6. iBeacon and home automation
      7. Beacon stickers
      8. Our tutorial
        1. Ranging beacons in the background
        2. Tracking locations using background modes
          1. Cheating the system
      9. Building our app
        1. Beginning the app with a database schema
        2. Using a little helper
        3. Master view controller implementation
          1. Configuring the view controller
          2. Fetching data from the Core Data framework
          3. Configuring the table cell
          4. Notifying the user
          5. Inserting new objects
          6. Ranging beacons
        4. Detailed view controller implementation
          1. Configuring the view
          2. Getting and setting properties
          3. Validating input
          4. Finishing off UI
        5. Adding NSLocationAlwaysUsageDescription
        6. Enabling the background mode
      10. Testing your app
      11. Summary
    14. 7. Vendor SDKs – Buying and Configuring Beacons
      1. Estimote motes and SDK
      2. ROXIMITY implementation
      3. Choosing the best platform for your requirements
      4. AltBeacon – the open beacon specification
      5. Using Estimote API 2.1
        1. Security
        2. Estimote SDK classes
          1. ESTBeacon
          2. ESTBeaconDelegate
          3. ESTBeaconManager
          4. ESTBeaconManagerDelegate
      6. Let's get building
        1. Adding EstimoteSDK
        2. Adding API access
        3. The helper class
        4. Configuring the master view controller
          1. Configuring our beacon manager
        5. Configuring the detail view controller
          1. Configuring the view
          2. Connecting and disconnecting from beacons
          3. Saving the changes
          4. Creating the view
      7. Testing your application
      8. Summary
    15. 8. Advanced Tutorial – iBeacon Museum
      1. Our exhibitions
      2. The museum map
      3. Our app structure
        1. The permission view
        2. The atrium view
        3. The exhibit view
      4. The supporting website
        1. Tracking our user's journey
      5. Our app design
      6. Building the application
        1. Creating the project
        2. Initializing the views
        3. Adding the CoreLocation functionality
        4. Determining the first view
        5. Configuring our permission view
          1. Adding controls
        6. Configuring the exhibit view
          1. Adding controls to the exhibit view
          2. Adding content methods
          3. Ranging beacons
        7. Configuring our atrium view
          1. Adding atrium view controls
      7. Time to test
      8. Summary
    16. 9. iBeacon Security – Understanding the Risks
      1. Beacon spoofing
        1. Defending against beacon spoofing
        2. Rotating UUIDs
      2. Beacon hacking
      3. Dispelling security myths
      4. Overcoming users' fears with good UX
      5. Summary
    17. Index

Product information

  • Title: Learning iBeacon
  • Author(s): Craig Gilchrist
  • Release date: November 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781784397128