As we all know, the latest WatchOS has been released which brings you faster performance, easy navigation, advanced fitness features, the Breathe app and more powerful Messages.
Being an iOS application developer we first need to check with its basic concepts, how the structure is defined, what kind of execution is there, etc.
Hence, we, 9series, are releasing our first article with basic concepts, frameworks, design patterns, architecture of Watch OS.
So, let’s start with this theoretical chapter:
What is WatchOS ?
WatchOS is the mobile operating system of the Apple Watch, developed by Apple Inc. It is based on the iOS operating system and has many similar features.
Developing for apple watch means providing your user important, impactful, helpful information in a most convenient way.
What is WatchKit?
WatchKit is Apple’s framework for building apps from Apple Watch,and it is bundled with Xcode. WatchKit watch app is not a standalone app instead they require to pair with an iOS app running on the user’s iPhone.The watch app you built will just be an extension of iPhone app.The iPhone app is responsible for managing and maintaining the Watch app.The iPhone app communicates with Watch app using watchKit.
The most important thing to understand about Watchkit app is that the Apple watch is just an external display for a program running on a connected iPhone.
Screen Size
The Apple watch will come in two screen size 38mm and 42mm with retina display. We do not need to design for both screen size Xcode will automatically adapt the layout to fit the screen size.There is no autolayout however watchkit use its own layout system.
Watch App Architecture
When the user selects your Watch app from the Home screen, watchOS launches it into the foreground. Your app remains in the foreground until the user dismisses it. Even when not in the foreground, your app may still run periodically. Specifically, apps run in the background when their complication is on the current watch face, when the app is in the dock, and when they are handling notifications. In addition, apps in the dock and apps with an active complications remain in memory, which lets the system launch them more quickly.
WatchKit App Project Structure
By adding a WatchKit application to our project, Xcode has created two targets for us, one for the WatchKit extension, and one for the WatchKit application.
The project created for Apple Watch consists of two separate bundles: a watch app and a watch kit extension. The watch app bundle contains the storyboards and resource files associated with all of your app’s user interfaces.The watch kit extension bundle contains the extension delegates and the controllers for managing those interfaces and for responding to user interactions.While these bundles are distributed inside an iOS app,they are then installed on the user’s Apple Watch and runs locally on the watch.
A WatchOS Project must include a Watch app, but may also include a glance, custom Notifications and complications. Each of these interface provides a unique way for users to interact with your app, often conveying important information to the user more quickly to the app’s main interface.The glance and notification are included in watch app’s storyboard.The code for managing the glance, notification and complications are part of the watch kit extension.
WatchApp Life Cycle
A. The applicationDidFinishLaunching method is called.
B. The applicationDidBecomeActive or applicationWillResignActive method is called.
C. The applicationWillEnterForeground or applicationDidEnterBackground method is called.
What Is an Interface Controller?
An interface controller is an instance of the WKInterfaceController class or a subclass thereof. The WKInterfaceController class is defined in the WatchKit framework.As you know, a view controller controls a view or view hierarchy. An interface controller, however, doesn’t control a view, instead it controls an interface, that is, a screenful of content.
An interface controller controls the behavior of the user interface. With an interface controller, you can configure the user interface of your WatchKit application and respond to the events which WatchKit application forwards to the WatchKit extension.
Interface Controller Life Cycle
The WKInterfaceController are analogous of UIViewController but do have same level access to the view component. For Example You cannot add dynamic Controls and restructure UI.
Types of User Interface
1. Normal Interface : The interface.storyboard consist of different scene and each scene has a corresponding WkInterfaceController.
2. Glance : Glance are Single Page, non-interactive UIs that are intended to provide summary or crucial Data. With a swipe from a bottom of watch face, a glance displays app’s most important information.The glance are non-scrolling and must fit in single screen and the information in glance are read only so glance do not contain buttons,switch and other interactive controls.Tap on glance launch watch app main screen.
3. Notification : Local and remote notifications are a way to communicate information to the user even when your app is not running. Both local and remote notification are supported. When an iOS app receives a notification, the operating system will decide whether the user should be notified of this event on the iPhone device or the paired Apple Watch device. If, for example, the iPhone is currently locked and the user recently interacted with the Apple Watch, the notification will most likely be delivered to the watch.
Not all iOS apps receive notifications, of course, but for those who perform it is important. The companion WatchKit app handle those notifications appropriately.
For many WatchKit apps it may not be necessary to make any changes to support notifications. In fact, the only step necessary to provide basic notification support for a WatchKit app is to add appropriate sized notification icons within the AppIcon image set of the WatchKit app bundle.
By default, if a notification arrives for an iOS app with a companion WatchKit app, the system will first decide whether to display the alert on the iPhone or the Apple Watch. In the event where the notification is delivered to the Apple Watch a “short-look” notification scene will first be displayed.
Complication:
Complications are small elements that appear on the watch face and provide quick access to frequently used data. A calendar app might,for example,use a complication so that the user can see the date and time of the next upcoming appointment simply by glancing at the clock face in which the complication has been enabled.The system provides built-in complications for weather information, upcoming calendar events, the user’s activity, and many more types of data.The size and placement of complication is determined by watchOS and is based on available space on the selected watch face.
Complication Families: Modular Small,Modular Large,Circular Small,Utilitarian Small,Utilitarian Large
Thanks for your time to read this article. We hope you enjoyed basic and core concept of Watch OS shared by our best iOS application developers. Stay tuned for our next article very soon which include the features of Watch OS 3.x.
As usual, feel free to share your queries, ideas or points to discuss on “[email protected]”.
Note – Images rights belong to their respective owners.