Chapter 7
WatchKit Extension Lifecycle

By now your watch app is pretty sophisticated. You’re moving between screens, sending data back and forth, and even replacing your entire UI as needed. But what about all of the other code you want to write—running code when the app starts, handling OS events, and the like? On iOS, you’d use your app delegate to handle the app’s lifecycle methods that run when the user starts or leaves the app. The equivalent on watchOS is the extension delegate, a class you’ll implement to handle the lifecycle events of your watch app. TapALap already has an extension delegate; it was created automatically by Xcode when we created the project, but it doesn’t do anything. In this chapter, you’ll implement TapALap’s extension delegate, allowing the app to safely continue a run if it’s suspended during one. We’ll also look at receiving notifications in the extension delegate, a common task for many apps, and look at Handoff, which allows an app to continue a user’s activity from one device to another. First, let’s add some lifecycle methods to TapALap.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.212.27