如何正确/以编程方式加入 SharePlay GroupSession?

发布于 2025-01-11 15:02:18 字数 917 浏览 3 评论 0原文

我在以编程方式加入共享游戏小组会话时遇到问题。

首先,我在一台设备上创建一个 SharePlay 活动,

await SharePlayGame().activate()

如果成功,创建者就会监听会话,

 private func startSession() async {
        for await session in SharePlayGame.sessions() {
            configureGroupSession(session) // do session stuff
        }
    }

到目前为止这一切都有效。现在第二台设备将加入。我只调用 startSession

但然后什么也没有发生。我的假设是创建的会话由 SharePlay 或 FaceTime 连接共享。

无论如何,当我打开 FaceTime 时,我看到有一个开放的会话。 FaceTime 为我提供了加入 GroupSession 的操作。如果我按此按钮,一切都会正常工作,并且我的设备已连接(见图)。该设备之间的任何进一步事件都按预期进行。

输入图片此处描述

当我使用 await SharePlayGame().activate() 进行加入过程时,会创建一个新的 SharePlay 组会话。这总是显示系统对话框(“你想替换当前的 SharePlay 会话吗?”)然后我的代码也可以工作,但这不是正确的方法。

加入(或查找?)GroupSession 并加入的正确方法是如何的。

I have problems to join a share play group session programmatically.

First I create on one device a SharePlay Activity

await SharePlayGame().activate()

If this was successful the creator listen to the session

 private func startSession() async {
        for await session in SharePlayGame.sessions() {
            configureGroupSession(session) // do session stuff
        }
    }

This is working so far. Now the second device will join. I call just startSession

But then nothing happens. My assumption was that the created session is shared by SharePlay or the FaceTime connection.

Anyway, when I open FaceTime I see that there is an open session. FaceTime offers me the action to join the GroupSession. If I press this everything work fine and my devices are connected (see image). Any further events between this devices are working as expected.

enter image description here

When I use await SharePlayGame().activate() for the joining process a new SharePlay Group Session is created. This always show the system dialog ("Do you want replace the current SharePlay Session?") Then my code works, too, but this cannot be the right way.

How is the correct way to join (or find?) the GroupSession and join.

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

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

发布评论

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

评论(2

不喜欢何必死缠烂打 2025-01-18 15:02:18

好吧,我发现了。 目前看来这是不可能的。我观看了所有 WWDC 视频并检查了整个文档。我尝试了很多大公司的其他应用程序,每个人都通过 FaceTime 加入会议。

编辑:我在 15.4 的发行说明中读到现在可以了。但我没有找到任何 iOS 文档。

Ok, I found it out. At the moment it seems that this is not possible. I watched all WWDC videos and check the whole documentation. I tried a lot of other apps from big players and everybody join the session by FaceTime.

Edit: I read in the release notes for 15.4 that it's now possible. But I did not find any iOS docu.

紫﹏色ふ单纯 2025-01-18 15:02:18

在我看来,您好像设置了一个 GroupSession,但尚未启动。

任何设备都可以等待特定 GroupActivity 上的 GroupSession。在其中一台设备激活 GroupActivity 之前,任何设备的会话都不会开始。两者是分开的。应用程序应在能够处理会话后立即启动等待 GroupSession 的任务。

决定何时激活 GroupActivity 也很有趣。当该活动的会话已存在时激活它将尝试替换现有会话。系统会打断用户,询问他们是否要替换现有会话,但结果不明确。

GroupSession 特定于特定的GroupActivity。一个应用程序可能能够参加多个活动的会话,但我还没有测试过。截至 WWDC 2022,Apple 表示应用程序可以在 GroupSession 上拥有多个 GroupSessionMessenger

It looks to me as though you set up a GroupSession, but haven't started one.

Any device can wait for a GroupSession on a particular GroupActivity. The session does not begin for any device until one of them activates the GroupActivity. The two are separate. The app should start a task waiting for a GroupSession as soon as it can handle the session.

There's also the fun of deciding when to activate the GroupActivity. Activating it when a session for that activity already exists will attempt to replace the existing session. The system will interrupt the user, asking if they want to replace the existing session, with ambiguous results.

A GroupSession is specific to a particular GroupActivity. An app may be able to participate is sessions for multiple activities, though I have not tested. As of WWDC 2022, Apple says that an app can have multiple GroupSessionMessenger on a GroupSession.

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