如何停用观看连接性会话?

发布于 2025-01-18 19:54:14 字数 701 浏览 0 评论 0原文

我正在使用Apple的WatchConnectivity Framework使用Companion WatchOS应用程序开发iOS应用程序。

On iOS side, after I open the app, I need to manually activate the WCSession to communicate with the Apple Watch like this

if ([WCSession isSupported]) {
    self.wcSession = [WCSession defaultSession];
    self.wcSession.delegate = self;
    [self.wcSession activateSession];
}

After I finish all necessary communications between the iPhone and the Apple Watch, I want to deactivate wcsession由于wcsession的激活是能量消耗的。我已经浏览了WatchConnectivity API,但还没有找到一种停用它的方法。除非我在iPhone上退出应用并再次重新打开该应用,否则我无法关闭连接。

有没有办法停用wcsession?非常感谢。

I am using Apple's WatchConnectivity framework to develop an iOS app with a companion WatchOS app.

On iOS side, after I open the app, I need to manually activate the WCSession to communicate with the Apple Watch like this

if ([WCSession isSupported]) {
    self.wcSession = [WCSession defaultSession];
    self.wcSession.delegate = self;
    [self.wcSession activateSession];
}

After I finish all necessary communications between the iPhone and the Apple Watch, I want to deactivate the WCSession since the activation of WCSession is energy consuming. I have looked through the WatchConnectivity API but haven't found a way to deactivate it. I cannot shutdown the connection unless I quit the app on the iPhone and reopen it again.

Is there a way to deactivate the WCSession? Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼前雾蒙蒙 2025-01-25 19:54:14

感谢@Paulw11,我认为一旦 WCSession 被激活,就无法将其停用。

Thanks to @Paulw11, I think there is no way to deactivate the WCSession once it has been activated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文