I think I've got my Connectivity stuff set up properly, was going off the Lister sample app. But, every time I try to send stuff via WCSession, it fails. Here's the code:
// iOS App, in my ViewController
override func viewDidLoad() {
super.viewDidLoad()
if WCSession.isSupported() {
WCSession.defaultSession().delegate = self
WCSession.defaultSession().activateSession()
}
}
func session(session: WCSession, didReceiveMessage message: [String : AnyObject]) {
let msg = message["message"] as! String
print("Got message! \(msg)")
}
// --------------
// WatchKit Extension - WKInterfaceController subclass
@IBAction func buttonTapped() {
let session = WCSession.defaultSession()
print("Session is reachable: \(session.reachable)") // this is false
let msg = ["message": "derp derp derp"]
session.sendMessage(msg, replyHandler: { reply in
print("Got reply: \(reply)")
}, errorHandler: { error in
print("error: \(error)")
})
}
The error in the errorHandler reads "Error Domain=WCErrorDomain Code=7004 "The operation couldn’t be completed. (WCErrorDomain error 7004.)"
My suspicion is that I don't have the simulators properly running at the same time. I am running them via the "WatchKit App" scheme in the "iPhone 6 + 38mm" simulators. The watch simulator starts the app, but the iPhone simulator does not.
I'm still new to watchOS dev, so not sure if there's another step.