I want to know if there's an API available that shows the availability of an Apple Watch. I don't want to write an Apple Watch App yet. I want to do some analysis to see what percentage of actual users have an Apple Watch, before investing time to develop a watch version (if possible, of course).
Swift 5
import WatchConnectivity
Then:
final class WatchSessionManager: NSObject {
private override init() {}
static let shared = WatchSessionManager()
func setup() {
guard WCSession.isSupported() else {
return
}
let session = WCSession.default
session.delegate = self
session.activate()
}
}
extension WatchSessionManager: WCSessionDelegate {
func sessionDidBecomeInactive(_ session: WCSession) {}
func sessionDidDeactivate(_ session: WCSession) {}
func session(
_ session: WCSession,
activationDidCompleteWith activationState: WCSessionActivationState,
error: Error?
) {
print("Apple Watch is paired: \(session.isPaired)")
}
}