如何正确/以编程方式加入 SharePlay GroupSession?
我在以编程方式加入共享游戏小组会话时遇到问题。
首先,我在一台设备上创建一个 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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我发现了。 目前看来这是不可能的。我观看了所有 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.
在我看来,您好像设置了一个 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 particularGroupActivity
. The session does not begin for any device until one of them activates theGroupActivity
. The two are separate. The app should start a task waiting for aGroupSession
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 particularGroupActivity
. 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 multipleGroupSessionMessenger
on aGroupSession
.