在Xcode 8 Beta 3中观看网络破坏

时间:2016-07-25 17:51:44

标签: ios xcode watchkit watchconnectivity

我从WatchKit扩展程序发送任何类型的http请求时收到以下错误:

WatchKit Extension[6128:479936] [WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterrupted

如果会话可以访问,则仅尝试发送消息,此时此消息即可。但是,当我检查会话对象时,我可以看到,当reacable为true且activationState为2(WCSessionActivationStateActivated)时,其他属性(如paired和watchAppInstalled)实际上是假的。

事实上,当我在模拟器或设备中使用应用程序时,错误只是每秒重复发送多次。我不知道发生了什么,但我在使用Xcode 8 Beta 3时才开始收到此错误。

App Delegate:

func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: NSError?) {
    if activationState == WCSessionActivationState.activated {
        NSLog("Activated")
    }

    if activationState == WCSessionActivationState.inactive {
        NSLog("Inactive")
    }

    if activationState == WCSessionActivationState.notActivated {
        NSLog("NotActivated")
    }
}

func sessionDidBecomeInactive(_ session: WCSession) {
    NSLog("sessionDidBecomeInactive")
}

func sessionDidDeactivate(_ session: WCSession) {
    NSLog("sessionDidDeactivate")

    // Begin the activation process for the new Apple Watch.
     WCSession.default().activate()
}

分机代表:

func applicationDidFinishLaunching() {
    // Perform any final initialization of your application.

    if (WCSession.isSupported()) {
        let session = WCSession.default()
        session.delegate = self
        session.activate()
        print("activating")
    }

}

func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: NSError?) {
    // ...
}

接口控制器

if WCSession.defaultSession().reachable { // ... }

我如何解决,或至少解决这个问题?

0 个答案:

没有答案