WCSession and Today Widget

自古美人都是妖i 提交于 2019-12-04 15:59:13

问题


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?


回答1:


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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!