I want to know if my users have Apple Watch. If many user do, so I will develop Apple Watch application extension for my iOS app. Can I know if even watch is not paired?
Asked
Active
Viewed 1,244 times
1
-
possible duplicate of https://stackoverflow.com/questions/29457558/check-if-iphone-is-paired-with-apple-watch – ivan_pozdeev Jun 19 '17 at 21:56
1 Answers
3
You should look at the WatchConnectivity framework. Especially, the isPaired method of WCSession
should solve your problem.
In your iPhone app's application(didFinishLaunchingWithOptions:)
method, set up and activate the WatchConnectivity session, since isPaired
only returns a valid value for an activated session.
//Set up WatchConnectivity
if WCSession.isSupported() {
let session = WCSession.default()
session.delegate = self
session.activate()
}
In func session(activationDidCompleteWith)
you can check if the iPhone is paired with an Apple Watch or not using this line of code:
let userHasAppleWatch = session.isPaired
.

Dávid Pásztor
- 51,403
- 9
- 85
- 116