2016-04-30 24 views
0

嗨,我有我的代碼的問題,它看起來像發送郵件是沒有得到所謂的出於某種原因,謝謝watchOS發送短消息沒有得到所謂的

if ([[WCSession defaultSession] isReachable]) { 
    NSLog(@"Initiating WCSession to Read iPhone Data"); 
    [[WCSession defaultSession] sendMessage:watchData replyHandler:^(NSDictionary *dataFromPhone) { 



     NSLog(@"Sending Empty Write Data Array to iPhone...%@", watchData); 


    } 
           errorHandler:^(NSError *error) { 
            // Log error 
            NSLog(@"Error: %@", error); 
           }]; 

} else { 
    //we aren't in range of the phone, they didn't bring it on their run 
    NSLog(@"Unable to connect to iPhone"); 
} 
+0

你是否激活了會話並分配了一個委託?此外,您意識到「發送...」日誌消息將不會出現,直到回覆處理程序被調用? – 2016-04-30 22:30:36

回答

0

從我所看到的是這樣的代碼,在iOS上運行,其控制Apple關注是否可達,但你要記住(如果你還沒有,當然完成),使無論從用下面的代碼設備的會話,因此使通信系統

if (WCSession.isSupported()) { 
    let session = WCSession.defaultSession() 

    session.delegate = self 
    session.activateSession() 
}