I've noticed that calls to updateApplicationContext() don't always result in func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) being called on the receiving end.
After several days of trial and error it seems the reason is that if the dictionary matches the same as previously passed in it is silently ignored, neither sent nor error thrown.
At first this may seem sensible since it could avoid repeatedly sending the same data due to programmer error. However consider when this is used to pass a shared app state dictionary between watch and iPhone in this basic/contrived example:
- Watch calls updateApplicationContext(["THEME_COLOR": "BLUE"]) ---> tells iPhone user has selected a blue theme on the watch, iPhone and watch should honour this choice
- iPhone calls updateApplicationContext(["THEME_COLOR": "RED"]) --> User changed their mind, would rather use red theme, iPhone and watch should honour the choice
- Watch calls updateApplicationContext(["THEME_COLOR": "BLUE"]) ---> user changes mind again, however this matches the last context update sent from the watch so it's ignored. Watch uses blue theme, iPhone continues to use red theme ERROR!
I can find no documentation stating this will happen. My work around for now is to always add a UUID string to the dictionary to make sure updates to the context are always sent.
Radar: 26001612