I am using WatchConnectivity to send messages between my swift iPhone / watch app.
When I receive a message on the iPhone, from the watch, I need to jump to the main thread.
The problem is; when the iPhone is in an inactive/not running state it never seems to complete that action.
The iPhone receives the message, but when it tries to dispatchQueue.main.async{} , it seems to time out. The code inside .async{} never gets called.
Here’s the code where it receives the message on the iPhone:
func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
print("Message recieved: ", message)
// We always make it to at least here, no matter what state the application is in.
DispatchQueue.main.async {
// This code is never called if the app is in an inactive/not running state.
// Do something...
}
}