Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apple Watch App Development

You're reading from  Apple Watch App Development

Product type Book
Published in Apr 2016
Publisher
ISBN-13 9781785886362
Pages 358 pages
Edition 1st Edition
Languages
Author (1):
Steven F. Daniel Steven F. Daniel
Profile icon Steven F. Daniel

Table of Contents (19) Chapters

Apple Watch App Development
Credits
About the Author
Acknowledgements
About the Reviewer
www.PacktPub.com
Preface
1. Introducing the Swift Programming Language 2. Understanding Apple Watch 3. Exploring WatchKit Controls 4. Using the Core Location and Watch Connectivity Frameworks 5. Navigating Around in WatchKit 6. Implementing Tables within Your App 7. Adding Menus to Your App 8. Incorporating the Glance Interface in Your App 9. Incorporating Notifications within Your App 10. Image Compression and Animation 11. Packaging and Deploying Your App Index

Chapter 5. Navigating Around in WatchKit

We will begin this chapter by building a Health Monitor application for the Apple Watch, leveraging the HealthKit framework so that you can interact and share data between the iOS device and the WatchKit extension. You will also learn about the various modes of navigation that are available within the WatchKit platform when interacting between interface controllers. We will explain how to use the HealthKit framework to access health data in order to do the following:

  • Read a person's heart rate

  • Count the number of steps that the person takes on a particular day

  • Access the user's profile data to extract their date of birth for calculating their age as well as their sex and blood type

To end the chapter, we will compile, build, and run the Health Monitor application and install this on the Apple Watch so that you can test the app and ensure that everything is working correctly.

This chapter includes the following topics:

  • Building a Health Monitor WatchKit...

Building the Health Monitor application


In this section, we will look at designing our user interface for our Health Monitor application. We will begin by developing the WatchKit portion of our application.

Before proceeding, we need to create our HealthMonitor project using Xcode. Simply follow the steps listed next:

  1. Launch Xcode from the /Applications folder.

  2. Choose Create a new Xcode project, or go to File | New Project.

  3. Select the iOS App with WatchKit App option from the list of available templates under the watchOS section, as shown in the following screenshot:

  4. Click on the Next button to proceed to the next step in the wizard.

  5. Next, enter HealthMonitor as the name for your project.

  6. Select Swift from the Language drop-down menu.

  7. Select iPhone from the Devices drop-down menu.

  8. Ensure that the Include Notification Scene checkbox has been selected.

  9. Click on the Next button to proceed to the next step in the wizard:

    Note

    The Organization Identifier for your app needs to be unique. Apple recommends...

Building and running the Health Monitor application


In this section, we will take a look at how to compile and run our Health Monitor application. You have the option of choosing to run your application on the watchOS device, or within the simulators for Apple Watch:

  1. To run the app, select the HealthMonitor WatchKit App scheme and choose your preferred device, as shown in the following screenshot:

  2. Next, build and run the application by selecting Product | Run from the Product menu, or alternatively, by pressing Command + R.

When the compilation completes, the Health Monitor app will be displayed. If you haven't previously allowed access to HealthKit, you will receive a dialog popup on both, Apple Watch and the iOS device.

In order to proceed, you will need to allow access to HealthKit so that you can retrieve the allowable characteristics that we specified within our app. You have the ability to turn on and off certain features so that they don't appear within the app. Tapping on the Open "HealthMonitor...

Summary


In this chapter, you learned about the HealthKit framework, and how you can leverage this framework to request and authorize health information, by coordinating between the iOS app and the WatchKit extension. You also learned how to create a new WatchKit class for our profile details controller, and how to update the interface controller to utilize this class.

In the next chapter, you will learn how to use the table controller within the WatchKit platform, how to set it up and configure it, how to populate it through code, determine when a user has selected a row, and respond to the action. You will also learn how to integrate with the PassKit framework, and how to handle Apple Pay payments.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Apple Watch App Development
Published in: Apr 2016 Publisher: ISBN-13: 9781785886362
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 $15.99/month. Cancel anytime}