Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning ibeacon

You're reading from   Learning ibeacon

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781784397128
Length 196 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Craig Gilchrist Craig Gilchrist
Author Profile Icon Craig Gilchrist
Craig Gilchrist
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

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

Testing our code

Plug in an iOS device to your Mac, and compile and debug the app. You should be presented with a lovely blank white screen. Because we're using CoreLocation, you need to give permission for the app to use your location. It's important that you agree to this:

Testing our code

Location permission dialog

Now, open the companion app on your Mac and choose the beacon profile named Chapter 1 : Default Beacon from the list on the left-hand side and then click on the power button, as shown in the following screenshot:

Testing our code

Using your Mac to broadcast your first iBeacon

What you've just simulated is your device entering a region. If this was a real scenario, the beacon would have been running all along and your device would come into range because you walk towards the beacon, but the companion app serves just as well in this instance.

If all was successful, you should see the following screenshot:

Testing our code

Successfully entered the region

Finally, test exiting the region by turning the beacon profile off in the companion OS X app. It may take up to 30 seconds for the app to register that you've left the region. Once the event fires, you should see the following screenshot:

Testing our code

Successfully exited the region

Tip

The reason for the delay is that the didExitRegion method is meant for tidying up resources after ranging beacons, which we'll cover in the later chapters. Apple's implementation includes a delay to ensure the event isn't fired when the Bluetooth signal may be subject to interference.

You have been reading a chapter from
Learning ibeacon
Published in: Nov 2014
Publisher:
ISBN-13: 9781784397128
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image