didReceiveMessage receives and responds to message but method not called

Im trying to implement messaging between the watch and my ios app but having a problem with some code not executing.

 

Watch app interface controller :

@IBAction func scheduleMeeting(_ sender: WKInterfaceButton) {
        if (WCSession.isSupported()) {
            session.sendMessage([ "scheduleMeeting": ["scheduleMeeting"] ], replyHandler: { (responses) -> Void in
                print("response: (responses)")
               
                self.statusLabel.setText(responses.first?.value as? String)
            }) { (err) -> Void in
                print("error: (err)")
            }
        }
    }

 

iOS app main view controller:

// WCSession Delegate protocol
    func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
       
        self.replyMsg = ["Message":"Intial"]
        DispatchQueue.main.async {
            do {
                print("test")
                //since we are passing true for asynchronous we cannot use the result of the call, the warning below is n/a
                try SymphonyCommunicator.addScheduledMeeting(self.scheduledMeeting, asynchronous: true)
               
                self.replyMsg = ["Message":"Successfully Scheduled"]
                replyHandler(self.replyMsg)
            } catch {
                print("Error: (error).")
                self.replyMsg = ["Message":"Error: (error)."]
                replyHandler(self.replyMsg)
            }
        }
        replyHandler(replyMsg)
}

As we can see from the console output (below), the message is received by the app and response is sent back.

response: [“Message”: Intial]

 

my problem is that none of the other code there is ran

  • print(“test1”) never shows on console
  • breakpoints within didReceiveMessage and Communicator.addScheduledMeeting are not hit
  • reply is not effected and always returns “intial” message

Side note I don’t know if its related but I feel that it might be and I should mention it.
to run my watch app I select ” WatchKit App” and hit play (its in this mode that my console output is from). however during this time, my app is only present on the watch emulator. If I try to open it on the iPhone simulator, it opens shows activity indicator, then goes black then back to home screen. If I select just “” and hit play the app runs fine. I can manually launch the watch app but nothing to the console nor any breakpoints.

Powered by WPeMatico

About

You may also like...

Comments are closed.