I've an app with a today extension and a watch app. From the main app WCSession works fine and data is transferred to the watch and received correctly but when I try to send or receive data through the WCSession in the today widget the property paired
and watchAppInstalled
of the session are set to false so calling transferUserInfo:
does nothing and session:didReceiveUserInfo:
is never called.
I know I can open the app using openURL
and then send the new data but I want to do that without leaving Notification Center.
Does anyone know a nice workaround for this problem?
If the watch app is running in the foreground, you should be able to send it a message via a Darwin notification. Take a look at MMWormhole.
It seems WCsession only works from the iOS app, not from any iOS extensions (share, today, keyboard, etc.), so for now you'll have to "relay" things via the app if you want to get it to the watch.
You should file an enhancement bug report with Apple explaining why you think it should be possible to use it from extensions too!
来源:https://stackoverflow.com/questions/32209138/wcsession-and-today-widget