WCSession和Today Widget [英] WCSession and Today Widget

查看:114
本文介绍了WCSession和Today Widget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序带有今天的扩展程序和手表应用程序。从主应用程序WCSession工作正常,数据传输到手表并正确接收,但当我尝试通过今天小部件中的WCSession发送或接收数据属性配对和会话的 watchAppInstalled 设置为false,因此调用 transferUserInfo:什么也不做, session:didReceiveUserInfo :永远不会被调用。

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.

我知道我可以使用 openURL 打开应用程序然后发送新数据,但我想在不离开通知中心的情况下这样做。
有没有人知道这个问题的一个很好的解决方法?

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?

推荐答案

如果手表应用程序在前台运行,你应该能够通过达尔文通知发送消息。请查看 MMWormhole

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.

这篇关于WCSession和Today Widget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆