apple watch and watchkit - a technical overview

39

Upload: sammy-sunny

Post on 15-Jul-2015

120 views

Category:

Mobile


1 download

TRANSCRIPT

Page 1: Apple Watch and WatchKit - A Technical Overview
Page 2: Apple Watch and WatchKit - A Technical Overview

Apple Watch and Apple WatchKit

Page 3: Apple Watch and WatchKit - A Technical Overview

• A look at Apple Watch

• WatchKit

• Structure and life cycle

• WatchKit Framework

• Creating watch app

Content

Page 4: Apple Watch and WatchKit - A Technical Overview

A look at Apple Watch

Page 5: Apple Watch and WatchKit - A Technical Overview

Size & Screens

Page 6: Apple Watch and WatchKit - A Technical Overview

Sensors

• Gyroscope • Measures angular velocity

• Determine orientation of device

• Accelerometer • Measures non-gravitational acceleration

• Type of activity

• Intensity of activity

• Heart Rate monitor • Measure heart response to exercise

• Physical training apps

Page 7: Apple Watch and WatchKit - A Technical Overview

Connectivity

• Bluetooth Connectivity

• Connectivity with phone

• Connectivity with headphone or headsets.

• Wireless Charging

Page 8: Apple Watch and WatchKit - A Technical Overview

Input Buttons and Gestures

• Buttons

• Digital crown

• Conversation button

• Gestures

• Vertical scrolling

• Horizontal swipe

• Left edge swipe

• Force touch

• Tap

Page 9: Apple Watch and WatchKit - A Technical Overview

Communication

• Glance

• Notification

• Short-look interface

• Long-look interface

• Watch Interface

• Hierarchical navigation interface

• Page-base navigation interface

Page 10: Apple Watch and WatchKit - A Technical Overview

WatchKit

Page 11: Apple Watch and WatchKit - A Technical Overview

WatchKit

The apple watch requires an iPhone paired with it to run the apps without an iPhone the watch apps will not work. For creating watch app we need two separate bundles

• WatchKit app

The watch kit app contains only storyboard and resource files associated with our apps UI.

• WatchKit extension

The WatchKit extension contains the code for managing the WatchKit app’s UI and for responding user interactions.

Since both of these bundle are packed in side the ios app so during the installation of the app the system prompts the user to install the watchkit app when a paired watch is present

Page 12: Apple Watch and WatchKit - A Technical Overview

Structure and life cycle

Page 13: Apple Watch and WatchKit - A Technical Overview

App Structure

Page 14: Apple Watch and WatchKit - A Technical Overview

Communication between Watchkit App

VS Watchkit extension

Page 15: Apple Watch and WatchKit - A Technical Overview

Watch app Launching

Page 16: Apple Watch and WatchKit - A Technical Overview

Watch app life cycle

Page 17: Apple Watch and WatchKit - A Technical Overview

WatchKit Framework

Page 18: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

The whole apple watch is managed by the

few classes the most used are as

• WKinterfaceController

• WKUserNotificationInterfaceController

• WKInterfaceDevice

• WKInterfaceObject

Page 19: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

WKInterfaceController in WatchKit is the same as

UIViewController in UIKit.

WKInterfaceController is a lot more restricted and has a

different life cycle. There are different methods to work with

as following.

UIViewController WKInterfaceController

likeviewDidLoad Init

loadView awakeWithContext

ViewWillAppear WillActivate

ViewWillDisappear didDeactivate

Page 20: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

• WKUserNotificationInterfaceController

Its a WKInterfaceController subclass that is used to display

custom notification interfaces.

• WKInterfaceDevice

This class contains basic information related to the iWatch.

This includes screen bounds, scale and current locale. You

can also use it to manage your images cache. WatchKit

allows you to store up to 20 MB of cached images on the

iWatch.

Page 21: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

• WKInterfaceObject

This is the base class for all UI controls supported by

WatchKit. As we cannot use UI views from UIKit. All we can

do is use the ones that WatchKit provides.

• WKInterfaceButton

• WKInterfaceDate

• WKInterfaceGroup

• WKInterfaceImage

• WKInterfaceLabel

• And more

Page 22: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

• Watchkit layout

WatchKit does not use Auto layout to position it’s element.

This is because it might have been too complex for the

slow iWatch. Instead we have a layout system that

positions elements relative to each other in a horizontal or

vertical order.

Page 23: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

• Glances

The apple watch is designed so that user can have a quick

access to the information from the app on iPhone. This is

achieved by “Glance Interface controller” which is non-

scrollable view with the precise info and user can launch

the app by tapping in it or can close it.

Apple prohibits using any interfaceObject on this screen

because “Glances do not support interactivity—tapping

on a glance automatically launches your WatchKit app”

Page 24: Apple Watch and WatchKit - A Technical Overview

A look at WatchKit framework

• Static notification interfaces

It is a simplified version of notification appearance, it contains static image and text. Only notification text can be changed.

• Dynamic notification interfaces

It allow you to specify a custom controller to display notification. Dynamic notification are not interactive and should be designed to display the info, tapping on it will launch the application

Page 25: Apple Watch and WatchKit - A Technical Overview

Sharing data with containing iOS

appThis can be done with by different methods which are as following

• By NSUserDefault

we can create and init the object of user default by initiating with initwithSuiteName

• By NSFilemanager

we can create a shared container using group id [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.com.swenggco.TodayExtensionApp"];

Page 26: Apple Watch and WatchKit - A Technical Overview

Sharing data with containing iOS

app

• By openParentApplication:reply: method

we can communicate directly with containing app by calling

the openParentApplication:reply: method, which iOS

launches or wakes the containing iOS app in the

background and calls

the application:handleWatchKitExtensionRequest:reply: m

ethod of its app delegate. The app delegate performs the

request using the provided dictionary and then returns a

reply to the WatchKit extension.

Page 27: Apple Watch and WatchKit - A Technical Overview

Creating watch app

• First we need to add watch app target to the iOS project.

To do this, select your project in the explorer and click the +

button at the bottom of the project.

Page 28: Apple Watch and WatchKit - A Technical Overview

Creating watch app

Page 29: Apple Watch and WatchKit - A Technical Overview

Select WatchKit App and hit Next

Page 30: Apple Watch and WatchKit - A Technical Overview

Select Finish when you are done

Page 31: Apple Watch and WatchKit - A Technical Overview

Now we have two new folders in

project directory

Page 32: Apple Watch and WatchKit - A Technical Overview

Setup an app group

App Groups are the scheme iOS uses to allow different apps to share data. If the apps have the right entitlements and proper provisioning, they can access a shared directory outside of their normal iOS sandbox.

To create groups we have to turn on “app groups” entitlement in Xcode for app and also for the extension.

When you flip that switch, Xcode will talk to the developer center to configure your app ID for app groups. Then you can select a group or create a new one.

Page 33: Apple Watch and WatchKit - A Technical Overview

Setup an app group

Page 34: Apple Watch and WatchKit - A Technical Overview

Setup an app group

Page 35: Apple Watch and WatchKit - A Technical Overview

Share a classes or framework

• We can also use a class a framework in watch extension

from the main project by selecting extension from “Target

membership” in “file inspector”.

Page 36: Apple Watch and WatchKit - A Technical Overview

Share a classes or framework

Page 37: Apple Watch and WatchKit - A Technical Overview

Now every thing is setup developing the watch

app. Add more WKinterfaceController start

building your watch app.

Page 38: Apple Watch and WatchKit - A Technical Overview

References

https://developer.apple.com/library/prerelease/ios/documen

tation/General/Conceptual/WatchKitProgrammingGuide/

https://developer.apple.com/library/prerelease/ios/documen

tation/UserExperience/Conceptual/WatchHumanInterfaceG

uidelines/index.html#//apple_ref/doc/uid/TP40014992-CH3-

SW1

http://swiftiostutorials.com/watchkit-tutorial/

http://stablekernel.com/blog/watchkit-sharing-app-data/

Page 39: Apple Watch and WatchKit - A Technical Overview

Need help launching your great Apple Watch App.

Swenggco SoftwareEmail: [email protected]

Web: www.swenggco-software.com

Thanks