My Experience with iWatch
WatchKit is Apple’s framework for building hybrid apps for the Apple iWatch, and first came bundled with Xcode 6.2.
WatchKit app contains 2 distinct parts:
- Apple iWatch – The iWatch app acts just like a thin client which contains the user interface and assets catalog. It is not designed to run any code from the watch extension not even the interaction handlers.
- iPhone app – It is actually an extension that is capable of executing logic and handling the user interactions in the iWatch user interface.
The communication between iWatch and the iOS extension app happens behind the screen using BTLE 4.0 without draining the watch`s battery. WatchKit extensions do not support background execution modes; they run only while the user is interacting with the corresponding app on the Apple Watch. Their iOS app has fewer restrictions and can be configured to run in the background or to gather information on behalf of the WatchKit extension. Activities that might require extra time to complete, such as fetching a user’s location, should therefore be performed by the iOS app and communicated back to the WatchKit extension.
With iOS 8, notifications became interactive. For the first time, we are able to do some minor customization on what notifications will do. WatchKit takes this even further by allowing apps to provide custom appearance and functionality to the notifications displayed on the iWatch.
WatchKit extension and iOS app run in separate sandbox environments. Thus they are normally not capable of sharing files or communicating directly with one another. So, to share files or user defaults between them we need to use a shared app group that will store the data.
WatchKit extension remains running only while the user is interacting with the app on iWatch. Interactions with iWatch are meant to be brief, so interface controllers should be lightweight and should never perform long-running tasks. When the user exits the app explicitly or stops interacting with the Apple Watch, iOS deactivates the current interface controller and suspends the extension.
A few points to remember while developing for iWatch:
- One of the best ways to make the WatchKit app fast is to divide the app’s work. Let WatchKit Extension control the UI on the watch and offload any long-running network requests, processor-intensive computations, or database management-style tasks to the iPhone app. iPhone allows code to run in the background, freeing up your WatchKit Extension for handling user input and updating your interface.
- The OLED screen of the Apple Watch gives better battery life with a black background. Black or dark gray backgrounds with a touch of color on the side or in text draw users’ attention to key elements of the interface without breaking the battery bank.
- Programmatically creating user interfaces for the watch app is not allowed.
- iWatch is a place for users to find the app’s most timely and relevant content, so be sure to provide them with exactly what is needed.
- Apple provides built-in classes to format numbers, dates, units of length, energy, mass, and more. By using them, the app will automatically use a format that is appropriate for users and where they live, letting you spend less time formatting data.
Author: Subhapam Kundu