我想我的收藏OS應用與iOS應用連接,並獲取了一些數據,但我收到以下錯誤,當我嘗試使用iOS應用連接連接:觀看OS應用程序無法與iOS應用
[WC] __28-[WCSession activateSession]_block_invoke_2 sessionReadyForInitialStateWithCompletionHandler failed due to NSXPCConnectionInterrupted
__44-[WCSession updateApplicationContext:error:]_block_invoke failed due to WCErrorCodeSessionNotActivated WatchConnectivity session has not been activated.
iOS應用代碼:
- (void) startSession{
if ([WCSession isSupported]) {
self.session = [WCSession defaultSession];
self.session.delegate = self;
[self.session activateSession];
}
}
關注OS代碼:
func startSession() {
if(session.activationState != .activated){
session.delegate = self
session.activate()
}
}
public func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?){
print("activationDidCompleteWith")
if activationState == WCSessionActivationState.activated {
NSLog("Activated")
if(WCSession.default().isReachable){
do {
try session.updateApplicationContext(
[WatchRequestKey : "updateData"]
)
}
catch let error as NSError {
print("\(error.localizedDescription)")
}
}
}
if activationState == WCSessionActivationState.inactive {
NSLog("Inactive")
}
if activationState == WCSessionActivationState.notActivated {
NSLog("NotActivated")
}
}
iOS應用程序是在客觀C和觀看的應用程序是在迅速
我執行我的iOS應用程序代碼,第一,它的委託方法運行,但是當我運行手錶OS的應用程序也無法執行任何委託方法,併產生上述錯誤。
任何更新對此有何看法?我與watchOS 2和iOS應用程序有同樣的問題。 – LucioB