SlideShare a Scribd company logo
1 of 27
Download to read offline
WATCHKIT 初探
Apple Watch 的概念與溝通實作
By Grady Zhuo
先來載⼀一下DEMO
https://github.com/gradyzhuo/WatchKitDemo
https://github.com/gradyzhuo/GZNotificationCenter
WATCH APP的⾓角⾊色
Watch apps extend the behavior of existing iOS
apps.The Watch app and WatchKit extension are
bundled together.
from WATCHKITTIPS FOR DEVELOPERS
WATCH APP
類似WEB中CLIENT的⾓角⾊色
WATCH APP可獨⽴立運作嗎?
現在不⾏行,⾼高度依賴IPHONE
需要藍⽛牙技術背景嗎?
不需要,已經被 WATCHKIT 封裝了
可以使⽤用藍⽛牙技術嗎?
不⾏行,可能只能抓到基本的藍⽛牙資訊
可以存取WATCH上的
SENSORS嗎?
無法,
但可能可以透過HEALTHKIT取得⼼心跳率的資料
LAUNCHING A WATCHKIT APP
Load initial
interface controller
Initialize UI Display UI
Storyboard
Launch
WatchKit App
Interface Controller
willActivate
awakeWithContext:
init
WatchKit Extension
The life cycle of an interface controller
Display UI
User interacts
with UI
User stops
interacting
Interface Controller
willActivate didDeactivateVarious action methods
WatchKit Extension
Suspend

extension
HOW IT WORK
HOW IT WORK
iOS App Bundle
WatchKit Extension
Code
Resource
WatchKit WatchKit
WatchKit App
Storyboard
Resource
HOW IT WORK
iOS App Bundle
WatchKit Extension
Code
Resource
WatchKit WatchKit
WatchKit App
Storyboard
Resource
HOW IT WORK
iOS App Bundle
WatchKit Extension
Code
Resource
WatchKit WatchKit
WatchKit App
Storyboard
Resource
Controller
Modal
View
讓 IOS 與 WATCH 對話
APPLE的⽅方案
• class func openParentApplication(userInfo: [NSObject :AnyObject], reply: (([NSObject :
AnyObject]!, NSError!) ->Void)?) -> Bool
openParentApplication:reply:
reply:
背景模式喚醒App
application:
handleWatchKitExtensionRequest:
reply:
reply([“ShowText”:“Hello”])
• func application(application: UIApplication, handleWatchKitExtensionRequest userInfo:
[NSObject :AnyObject]?, reply: (([NSObject :AnyObject]!) ->Void)!)
這是從WATCH APP主動呼叫
那 IOS 可以主動控制嗎?
NO
確切來說是APPLE沒有在WATCHKIT中提供
What!
以前⽤用過的技巧
• NSNotificationCenter
• 不可⾏行,這只在同⼀一 App 內有效,對App-Extension無效
• KVO(Key-Value-Observer)
• 不可⾏行,同上,這也無法使⽤用在⾮非同⼀一App下的物件
• Hand Off
• 可⾏行,但可能會不夠即時,也算Apple的⽅方案之⼀一。
向底層借東⻄西⽤用⽤用
CFNotificationCenter
CFNotificationCenter
• 這是⼀一個系統級的實作,與NSNotificationCenter
⽤用途⼀一樣,只是層級更低。
• 可使App與Extension間進⾏行通知。
• 使⽤用上有限制,無法傳遞資料,需通過
NSUserDefaults、App Group或透過Server進⾏行
資源共享。
TWO SIZE
38 mm 42 mm
THREE MODES
Watch App Glance Notification
SIMULATOR
SIMULATOR
RESOURCES
• WATCHKITTIPS FOR DEVELOPERS
• WatchKit: Using Handoff in an Apple Watch App
• “My Biggest WatchKit Mistake”
• WatchKit: Initial Impressions
• App与Extensions间通信共享数据
• WatchKit - Zonble
• [iOS] Watch App Architecture | 逍遙⽂文⼯工作室
DEMO & 實作

More Related Content

Similar to WatchKit 初探

Make an i os application
Make an i os applicationMake an i os application
Make an i os applicationfroooo
 
App inventor 演講簡報
App inventor 演講簡報App inventor 演講簡報
App inventor 演講簡報David Huang
 
Auto fac的介紹 20131018
Auto fac的介紹 20131018Auto fac的介紹 20131018
Auto fac的介紹 20131018LearningTech
 
Auto fac的介紹 20131018
Auto fac的介紹 20131018Auto fac的介紹 20131018
Auto fac的介紹 20131018LearningTech
 
《氪周刊:互联网创业必读》(第76期)
《氪周刊:互联网创业必读》(第76期)《氪周刊:互联网创业必读》(第76期)
《氪周刊:互联网创业必读》(第76期)36Kr.com
 
《氪周刊:互联网创业必读》(第74期)
《氪周刊:互联网创业必读》(第74期)《氪周刊:互联网创业必读》(第74期)
《氪周刊:互联网创业必读》(第74期)36Kr.com
 
Appium手机自动化测试 tester home公开课
Appium手机自动化测试 tester home公开课Appium手机自动化测试 tester home公开课
Appium手机自动化测试 tester home公开课lihuazhang
 
How to integrate GitLab CICD into B2B service
How to integrate GitLab CICD into B2B serviceHow to integrate GitLab CICD into B2B service
How to integrate GitLab CICD into B2B serviceAlex Su
 
20141212 html5 及微軟跨平台佈局 long
20141212 html5 及微軟跨平台佈局   long20141212 html5 及微軟跨平台佈局   long
20141212 html5 及微軟跨平台佈局 longMeng-Ru (Raymond) Tsai
 
浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用SpeedyCloud
 
2014南部創新應用工具研討會 快速開發行動 app
2014南部創新應用工具研討會 快速開發行動 app2014南部創新應用工具研討會 快速開發行動 app
2014南部創新應用工具研討會 快速開發行動 app益祥 許
 
Otto97完全製作手冊 v0.9
Otto97完全製作手冊 v0.9Otto97完全製作手冊 v0.9
Otto97完全製作手冊 v0.9Bear Wang
 
《氪周刊:互联网创业必读》(第58期).pdf
《氪周刊:互联网创业必读》(第58期).pdf《氪周刊:互联网创业必读》(第58期).pdf
《氪周刊:互联网创业必读》(第58期).pdfChada Chiu
 
浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用Leo Zhou
 
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519August Lin
 
導入 Flutter 前你應該知道的事
導入 Flutter 前你應該知道的事導入 Flutter 前你應該知道的事
導入 Flutter 前你應該知道的事Weizhong Yang
 
天鹅绒围脖
天鹅绒围脖天鹅绒围脖
天鹅绒围脖Liu Chao
 
第一次 Mobile App 就上手
第一次 Mobile App 就上手第一次 Mobile App 就上手
第一次 Mobile App 就上手Ying-Hsiang Liao
 
互联网产品监测报告(第五十二期)
互联网产品监测报告(第五十二期)互联网产品监测报告(第五十二期)
互联网产品监测报告(第五十二期)小熊 张
 
2013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 32013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 3樂平 大俠
 

Similar to WatchKit 初探 (20)

Make an i os application
Make an i os applicationMake an i os application
Make an i os application
 
App inventor 演講簡報
App inventor 演講簡報App inventor 演講簡報
App inventor 演講簡報
 
Auto fac的介紹 20131018
Auto fac的介紹 20131018Auto fac的介紹 20131018
Auto fac的介紹 20131018
 
Auto fac的介紹 20131018
Auto fac的介紹 20131018Auto fac的介紹 20131018
Auto fac的介紹 20131018
 
《氪周刊:互联网创业必读》(第76期)
《氪周刊:互联网创业必读》(第76期)《氪周刊:互联网创业必读》(第76期)
《氪周刊:互联网创业必读》(第76期)
 
《氪周刊:互联网创业必读》(第74期)
《氪周刊:互联网创业必读》(第74期)《氪周刊:互联网创业必读》(第74期)
《氪周刊:互联网创业必读》(第74期)
 
Appium手机自动化测试 tester home公开课
Appium手机自动化测试 tester home公开课Appium手机自动化测试 tester home公开课
Appium手机自动化测试 tester home公开课
 
How to integrate GitLab CICD into B2B service
How to integrate GitLab CICD into B2B serviceHow to integrate GitLab CICD into B2B service
How to integrate GitLab CICD into B2B service
 
20141212 html5 及微軟跨平台佈局 long
20141212 html5 及微軟跨平台佈局   long20141212 html5 及微軟跨平台佈局   long
20141212 html5 及微軟跨平台佈局 long
 
浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用
 
2014南部創新應用工具研討會 快速開發行動 app
2014南部創新應用工具研討會 快速開發行動 app2014南部創新應用工具研討會 快速開發行動 app
2014南部創新應用工具研討會 快速開發行動 app
 
Otto97完全製作手冊 v0.9
Otto97完全製作手冊 v0.9Otto97完全製作手冊 v0.9
Otto97完全製作手冊 v0.9
 
《氪周刊:互联网创业必读》(第58期).pdf
《氪周刊:互联网创业必读》(第58期).pdf《氪周刊:互联网创业必读》(第58期).pdf
《氪周刊:互联网创业必读》(第58期).pdf
 
浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用浅析Python多线程与多进程的使用
浅析Python多线程与多进程的使用
 
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
 
導入 Flutter 前你應該知道的事
導入 Flutter 前你應該知道的事導入 Flutter 前你應該知道的事
導入 Flutter 前你應該知道的事
 
天鹅绒围脖
天鹅绒围脖天鹅绒围脖
天鹅绒围脖
 
第一次 Mobile App 就上手
第一次 Mobile App 就上手第一次 Mobile App 就上手
第一次 Mobile App 就上手
 
互联网产品监测报告(第五十二期)
互联网产品监测报告(第五十二期)互联网产品监测报告(第五十二期)
互联网产品监测报告(第五十二期)
 
2013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 32013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 3
 

WatchKit 初探