Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning ibeacon
Learning ibeacon

Learning ibeacon:

Arrow left icon
Profile Icon Craig Gilchrist
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (7 Ratings)
Paperback Nov 2014 196 pages 1st Edition
eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Craig Gilchrist
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (7 Ratings)
Paperback Nov 2014 196 pages 1st Edition
eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Learning ibeacon

Chapter 2. Detecting Beacons – Showing an Advert

In the previous chapter, we introduced you to the amazing possibilities of iBeacon and brought the UUID/major/minor broadcasting triplet to your attention. We also built our first, albeit very simple, app that detected the presence of beacons.

In this chapter, we're going to expand our knowledge and get an in-depth understanding of the broadcasting triplet, and we'll expand on some of the important classes within the Core Location framework.

To help demonstrate the more in-depth concepts, we'll build an app that shows different advertisements depending on the major and minor values of the beacon that it detects. We'll be using the context of an imaginary department store called Matey's. Matey's are currently undergoing iBeacon trials in their flagship London store and at the moment are giving offers on their different-themed restaurants and also on their ladies clothing to users who are using their...

Uses of the UUID/major/minor broadcasting triplet

In the last chapter, we covered the reasons behind the broadcasting triplet; we're going to use the triplet with a more realistic scenario. Let's go over the three values again in some more detail.

UUID – Universally Unique Identifier

The UUID is meant to be unique to your app. It can be spoofed, which we'll cover in Chapter 9, iBeacon Security – Understanding the Risks, but generally, your app would be the only app looking for that UUID.

The UUID identifies a region, which is the maximum broadcast range of a beacon from its center point. Think of a region as a circle of broadcast with the beacon in the middle.

If lots of beacons with the same UUID have overlapping broadcasting ranges, then the region is represented by the broadcasting range of all the beacons combined as shown in the following figure. The combined range of all the beacons with the same UUID becomes the region.

UUID – Universally Unique Identifier

Broadcast range

More specifically, the...

Understanding Core Location

The Core Location framework lets you determine the current location or heading associated with the device. The framework has been around since 2008 and was present in iOS 2.0. Up until the release of iOS 7, the framework was only used for geolocation based on GPS coordinates and so was suitable only for outdoor location.

The framework got a new set of classes and new methods were added to the existing classes to accommodate the beacon-based location functionality. Let's explore a few of these classes in more detail.

The CLBeaconRegion class

Geo-fencing (geofencing) is a feature in a software program that uses the global positioning system (GPS) or radio frequency identification (RFID) to define geographical boundaries. A geofence is a virtual barrier.

The CLBeaconRegion class defines a geofenced boundary identified by a UUID and the collective range of all physical beacons with the same UUID. When a device matching the CLBeaconRegion UUID comes in range, the...

Creating a CLLocationManager class

The CLLocationManager class is used to track both geolocation and proximity based on beacons. To start tracking beacon regions using the CLLocationManager class, we need to do the following:

  1. Create an instance of CLLocationManager.
  2. Assign an object conforming to the CLLocationManagerDelegate protocol to the delegate property.
  3. Call the appropriate start method to begin the delivery of events.

All location- and heading-related updates are delivered to the associated delegate object, which is a custom object that you provide.

Defining a CLLocationManager class line by line

Consider the following steps to define a CLLocationManager class line by line:

  1. Every class that needs to be notified about CLLocationManager events needs to first import the Core Location framework (usually in the header file) as shown:
    #import <CoreLocation/CoreLocation.h>
  2. Then, once the framework is imported, the class needs to declare itself as implementing the CLLocationManagerDelegate...

Understanding iBeacon permissions

It's important to understand that apps using the Core Location framework are essentially monitoring location, and therefore, they have to ask the user for their permission. The authorization status of a given application is managed by the system and determined by several factors. Applications must be explicitly authorized to use location services by the user, and the current location services must themselves be enabled for the system. A request for user authorization is displayed automatically when your application first attempts to use location services.

Requesting the location can be a fine balancing act. Asking for permission at a point in an app, when your user wouldn't think it was relevant, makes it more likely that they will decline it. It makes more sense to tell the users why you're requesting their location and why it benefits them before requesting it so as not to scare away your more squeamish users.

Building those kinds of information...

Building the tutorial app

To demonstrate the knowledge gained in this chapter, we're going to build an app for our imaginary department store Matey's. Matey's is trialing iBeacons with their app Matey's offers. People with the app get special offers in store as we explained earlier.

For the app, we're going to start a single view application containing two controllers. The first is the default view controller, which will act as our CLLocationManagerDelegate, the second is a view controller that will be shown modally and shows the details of the offer relating to the beacon we've come into proximity with.

The final thing to consider is that we'll only show each offer once in a session and we can only show an offer if one isn't showing. Shall we begin?

Creating the app

Let's start by firing up Xcode and choosing a new single view application just as we did in the previous chapter. Choose these values for the new project:

  • Product Name: Matey's Offers...

Uses of the UUID/major/minor broadcasting triplet


In the last chapter, we covered the reasons behind the broadcasting triplet; we're going to use the triplet with a more realistic scenario. Let's go over the three values again in some more detail.

UUID – Universally Unique Identifier

The UUID is meant to be unique to your app. It can be spoofed, which we'll cover in Chapter 9, iBeacon Security – Understanding the Risks, but generally, your app would be the only app looking for that UUID.

The UUID identifies a region, which is the maximum broadcast range of a beacon from its center point. Think of a region as a circle of broadcast with the beacon in the middle.

If lots of beacons with the same UUID have overlapping broadcasting ranges, then the region is represented by the broadcasting range of all the beacons combined as shown in the following figure. The combined range of all the beacons with the same UUID becomes the region.

Broadcast range

More specifically, the region is represented by an...

Left arrow icon Right arrow icon

Description

This book is intended for iOS developers who are curious to learn about iBeacon and want to start building applications for iOS. You will gain everything you need to know to master indoor location functionality using Bluetooth beacon technology. No knowledge of iBeacon is assumed.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 25, 2014
Length: 196 pages
Edition : 1st
Language : English
ISBN-13 : 9781784397128
Category :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Nov 25, 2014
Length: 196 pages
Edition : 1st
Language : English
ISBN-13 : 9781784397128
Category :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Mastering JavaScript Design Patterns
€36.99
Learning ibeacon
€24.99
Swift Essentials
€41.99
Total 103.97 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Welcome to iBeacon Chevron down icon Chevron up icon
2. Detecting Beacons – Showing an Advert Chevron down icon Chevron up icon
3. Broadcasting Advertisements – Sending Offers Chevron down icon Chevron up icon
4. Ranging Beacons – Hunting for Treasure Chevron down icon Chevron up icon
5. Detecting Beacons in the Background – Location Dating Chevron down icon Chevron up icon
6. Leaving Regions – Don't Forget Your Stuff Chevron down icon Chevron up icon
7. Vendor SDKs – Buying and Configuring Beacons Chevron down icon Chevron up icon
8. Advanced Tutorial – iBeacon Museum Chevron down icon Chevron up icon
9. iBeacon Security – Understanding the Risks Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(7 Ratings)
5 star 42.9%
4 star 57.1%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Cheopys Feb 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A very clear and comprehensive introduction and explanation to this vital new technology. Presentation is staged and linear, examples are clear and useful, not nonsense placeholder code. I'd quibble over the accessibility to novice iOS developers, however. The technology is too dependent on deep understanding of objective C and iOS frameworks for any novice.A singular book, recommended.
Amazon Verified review Amazon
serafino sorleti Jan 27, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Beacon technology was something I was always curious about (both as user and developer), and finally I discovered this book that helped me to understand what a beacon is and how I can use the beacon technology together with iOS SDK to develop either an advertising or a dating or an indoor location or an IoT app. I'm an iOS developer since 2009 and it was very easy for me to understand the author's beacon technology description and how to interact with it using the iOS SDK. Furthermore, the book describes beacons powered apps security issues (and, most important thing, how to solve/minimize these issues). As an iOS developer I really appreciated the good description of background/foreground beacon related location events handling and the OS X companion software that allows book readers to test book objective-c project without the need of buying an actual beacon device (but the author lists the most known beacon devices on the market, their prices, pros and cons of their sdk in a very good and helpful way). Recommended!
Amazon Verified review Amazon
David A. P.A. Jun 30, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book gives you a great walkthrough the ibeacon technology, how to create some apps, important information on security and concerns, if you are a Marketer or a developer its a great option to get into the ibeacon world
Amazon Verified review Amazon
Kevin Kirkhoff Jan 20, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
While I didn’t do all the examples, this book shed a lot of light on the iBeacon technology. Contrary to what the author states early on though, this is not a book for beginners. It’s for intermediate to advanced Objective-C developers who either want to learn iBeacon or they have a project that utilizes it and need a crash course.The author spent a good amount of productive time explaining what iBeacon was and how it can be used. He then jumps into a standard “Hello World” example.The rest of the book is spent on the various concepts…detecting beacons, beacon ranges, advertising beacons, and leaving beacon regions. He even spends some time showing beacon vender SDKs. He ends up the book with some interesting security issues to be aware of.He even has a really cool demo that features beacons in different rooms of a museum.I would highly recommend this book to any experienced Objective-C iOS developers that want to learn (i.e. immerse themselves) in the world of iBeacons.
Amazon Verified review Amazon
James Ransom Jan 13, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book contains valuable information that is readily available to the reader. It strikes a nice balance of basic knowledge and info pertaining to the technology, as well as delving in deeper for those who are truly serious about getting to know the outs and ins of iBeacon.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.