error: Error Domain=WCErrorDomain Code=7001 "Unknown WatchConnectivity error."
Third days after install Xcode7 I can not fix my problem. I was stupid and converted my watch app to watchOS 2. And it does not connect to parent iOS app.
I wrote very simple code:
1.
import WatchKit
import Foundation
import WatchConnectivity
class InterfaceController: WKInterfaceController {
...
override func willActivate() {
...
let requestValues = ["command" : "start"]
let session = WCSession.defaultSession()
session.sendMessage(requestValues, replyHandler: { reply in
print(reply["status"] as? String)
}, errorHandler: { error in
print("error: \(error)")
})
2.
import WatchKit
import WatchConnectivity
class ExtensionDelegate: NSObject, WKExtensionDelegate, WCSessionDelegate {
func applicationDidFinishLaunching() {
/
if (WCSession.isSupported()) {
let session = WCSession.defaultSession()
session.delegate = self
session.activateSession()
}
}
3.
import UIKit
import WatchConnectivity
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, WCSessionDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if (WCSession.isSupported()) {
let session = WCSession.defaultSession()
session.delegate = self
session.activateSession()
...
func session(session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler: ([String : AnyObject]) -> Void) {
var replyValues = Dictionary<String, AnyObject>()
switch message["command"] as! String {
case "start" :
replyValues["status"] = "Playing"
default:
break
}
replyHandler(replyValues)
}
Help me please!!!