I'm working in a game where I integrate matchmaker and it's working fine when I try with two devices under same wifi network, but in the moment I use 5g mobile network and I do the matchmaker, I can still see each other but the game did not start and I see error sending data to the remote player.
The game is not yet published and I'm using TestFlight for the clients.
GameKit
RSS for tagCreate apps that allow players to interact with each other using GameKit.
Posts under GameKit tag
75 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I'm trying to implement multiplayer invitation from game center for macos, ios, tvos following this https://developer.apple.com/documentation/gamekit/finding_multiple_players_for_a_game?language=objc
Implementation works for tvos and ios, I can invite my friends, Start Game and continue sending data. But macos still doesn't work at all. I tried using build that works on iOS to invite macos player, but my mac cannot even receive the invitation notification from game center (game is installed already on mac).
While from mac, my invitation process is stuck here until it's failed
Is there any specific setting on macos to enable game center invitation?
Hi all!
My new iOS app (first one in Swift and SpriteKit, was using ObjectiveC and Cocos2D before, a few years back) - got rejected with the dreaded "We were unable to review your app as it crashed on launch.",
That's especially bad news when it never ever crashed on any on our devices when testing (variety of phones, iPads and all sort of iOS) either in debug or release, before submission.
So no luck repro-ing!
The crashlog text file apple review team sent back, renamed as .crash, seems to open in Xcode (right click on it) when linked to the right project and seems to point in the leaderboard code fetching the local authenticated user's score. This is some code that I shamelessly copy/pasted from a StackOverflow page a few months ago, and seemed to work right away so moved-on back then, but something must be unsafe in there (sorry, bit of a rookie with Swift optionals etc).
Any help would be much appreciated as this code seems to work fine in debug, without warnings or anything, and also works fine in release using TestFlight - so we simply cannot repro the apple QA issue, and we need to fix it blind!
This is the function below that is crashing, right on the line that has the "{ player, _, _ in ":
func sync_hiscore()
{
if (GKLocalPlayer.local.isAuthenticated)
{
if #available(iOS 14.0, *)
{
GKLeaderboard.loadLeaderboards( IDs: ["HatStacker_LD01"] )
{ leaderboards, _ in leaderboards?[0].loadEntries( for: [GKLocalPlayer.local], timeScope: .allTime )
{ player, _, _ in // <<<< !!! CRASHES HERE!!
if ( player!.score > player_hiscore)
{
player_hiscore = player!.score
}
}
}
}
}
}
I've also attached the full crashlog if that's of any help!
Many thanks all, sorry for such a Swift rookie question, but to add to the confusion this is also the first time one of our apps gets rejected for such an obvious bad crash at launch, that no one has seen during our weeks of testing!
Any idea why it's only in release and only in the apple HQ/review env that we get that error? Could they have an invalid Game Center account that is confusing the "player" score fetching?
Cheers,
JBB
HatStacker_build4.crash
In our multiplayer game prototype, we experience a ping of 300 ms (at best) when using Game Center and GKMatch to send data between players, over the GKMatch.SendDataMode.unreliable channel. This latency is not suitable for a real-time game.
When we tested alternative services like Unity's Relay under identical conditions (location, devices, and Wi-Fi), we achieved a ping of 120 ms.
Is a ping value of 300 ms typical when using Game Center?
I can think of possible reasons in case it's not typical, but I can't be sure:
Is there a different behavior (servers relaying peer-to-peer connections) when the game is not yet released on the store?
We're in Europe, maybe this is normal in Europe and better in US?
I'm working in a game that it was working perfectly with Game Center (remote game with 1 remote player), but since last Sunday I'm having errors when I try to start a remote game.
I have 2 errors, one says FAILED when I invite a friend to play. In this case, the other device never gets the notification.
The other error sent the notification, but when I tap on it (on the other device), it fails saying that it couldn't communicate with the server). The main device it says "INVITED" but it doesn't say anything else.
I haven't found anyone else having the same issue, so I wonder if it's my fault, although I haven't change that part of the code since the last time I tested it.
Is it someone else here having similar problems? or knows what should I review?
thank you all, and have a great year!
How to get current player score and position? Thanks!
I'm trying to display the native GameCenter interface from Unity (I've already tried Bounded and Unbouded Volume Mode, that is, with and without Full Immersive Mode) but I can't display this interface.
If I use Unity's SocialAPI (https://docs.unity3d.com/ScriptReference/Social.ShowLeaderboardUI.html), nothing is displayed, and I get the following message in XCode (simulator):
[u 9C225095-F55E-42CC-8136-957279631DF3:m (null)] [com.apple.GameCenterUI.GameCenterDashboardExtension(1.0)] Connection to plugin interrupted while in use.
setViewControllers:animated: called on <GKGameCenterViewController 0x106825600> while an existing transition or presentation is occurring; the navigation stack will not be updated.
Type: Notice | Timestamp: 2023-12-08 12:13:50.585973+01:00 | Process: leaderboard-test | Library: UIKitCore | TID: 0x3e57bd
viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
Type: Notice | Timestamp: 2023-12-08 12:13:50.586997+01:00 | Process: leaderboard-test | Library: UIKitCore | TID: 0x3e57bd
[u 9C225095-F55E-42CC-8136-957279631DF3:m (null)] [com.apple.GameCenterUI.GameCenterDashboardExtension(1.0)] Connection to plugin invalidated while in use.
Type: Error | Timestamp: 2023-12-08 12:13:50.588393+01:00 | Process: leaderboard-test | Library: PlugInKit | Subsystem: com.apple.PlugInKit | Category: lifecycle | TID: 0x3e5a18
If I try to do it using Apple's plugin for GameCenter (GameKitWrapper) adapted to VisionOS, the application crashes with the following error:
"Presentations are not permitted within volumetric window scenes."
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Presentations are not permitted within volumetric window scenes.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804a510c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180082f50 objc_exception_throw + 56
2 UIKitCore 0x0000000184bc2798 -[UIViewController _presentViewController:withAnimationController:completion:] + 1136
3 UIKitCore 0x0000000184bc4000 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 88
4 UIKitCore 0x0000000184bc42d0 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 484
5 UIKitCore 0x0000000184bc3f6c -[UIViewController _presentViewController:animated:completion:] + 160
6 UIKitCore 0x0000000184bc4374 -[UIViewController presentViewController:animate
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Presentations are not permitted within volumetric window scenes.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804a510c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180082f50 objc_exception_throw + 56
2 UIKitCore 0x0000000184bc2798 -[UIViewController _presentViewController:withAnimationController:completion:] + 1136
3 UIKitCore 0x0000000184bc4000 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 88
4 UIKitCore 0x0000000184bc42d0 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 484
5 UIKitCore 0x0000000184bc3f6c -[UIViewController _presentViewController:animated:completion:] + 160
6 UIKitCore 0x0000000184bc4374 -[UIViewController presentViewController:animated:completion:] + 140
7 GameKitWrapper 0x00000001057aa864 $s14GameKitWrapper34GKGameCenterViewController_Present7pointer6taskId9onSuccessySv_s5Int64VyAGXCtF ...
)
The code that produces this crash is the following (trying to display the GameCenter UI):
let viewController = UIApplication.shared.windows.first!.rootViewController;
viewController?.present(target, animated: true);
@_cdecl("GKGameCenterViewController_Present")
public func GKGameCenterViewController_Present
(
pointer: UnsafeMutableRawPointer,
taskId: Int64,
onSuccess: @escaping SuccessTaskCallback
)
{
let target = Unmanaged<GKGameCenterViewController>.fromOpaque(pointer).takeUnretainedValue();
_currentPresentingGameCenterDelegate = GameKitUIDelegateHandler(taskId: taskId, onSuccess: onSuccess);
target.gameCenterDelegate = _currentPresentingGameCenterDelegate;
#if os(iOS) || os(tvOS) || os(visionOS)
let viewController = UIApplication.shared.windows.first!.rootViewController;
viewController?.present(target, animated: true);
#endif
}
Is there a way to present the GameCenter UI overlaid on the Unity app?
Hello,
I'm working on a game application and I've been wondering about how I can separate the GameKit Leaderboards I'm using for testing purpose and the ones that would be "live" (i.e: only for the users)
I've been point out that I can attach leaderboards to an app version but it makes me wondering about compatibility.
I'm working on the application in version 1.1.
My users are using the application in version 1.0 (with their leaderboards).
Then I'm releasing a version 1.2.
It would means I need to attach all the leaderboards from version 1.0 to version 1.2 and to me it's very tedious.
What would be the best practice with using leaderboards on multiple environments?
Thanks
Hi everyone,
I'm trying to implement matchmaking in visionOS using GameKit and GameCenter.
I'm following the example project that been shared but I get an error.
Error: The requested operation could not be completed because you are not signed in to iCloud..
I'm getting this error as a result of matchmaking. I'm already logged in to iCloud in Vision Pro Simulator. I've tried to switch off-on every related settings but didn't work.
I'm using latest Xcode Dev Beta and visionOS Beta v6.
Would you mind share me any workaround?
Regards,
Melih
Hi guys,
I want to build a referral program wherein current users are rewarded for inviting friends to join my app/website.
I also wanted to keep the accounts linked so that recruiting users can get rewarded every time a new user they recruited purchases something.
I want to just give the users points, I'm not offering cash or subscription discounts. similar to how game invites work.
through my research into the topic I have found dynamic links with flutter and firebase. deep deferred links, QR code deferred links, and some work around that included taking the user to a website copying the code to their clipboard, then pasting it into a hidden textfield to verify and track the code
can anyone help me get started?
I have implemented a standard GKLeaderboard in my app. The leaderboard includes the player's avatar, display name, and the score.
I only use functionality provided by GameKit without any custom server functionality. I don't even have an own server.
Still, my app got rejected with the following notice:
We noticed that your app does not obtain the user's consent prior to uploading users' scores to a global leaderboard. To collect personal data with your app, you must make it clear to the user that their personal data will be uploaded to your server.
What should I do here? Do I really have to obtain user's consent before uploading his score to Game Center?
Hi All!
I'm being asked to migrate an app which utilizes iCloud KVS (Key Value Storage). This ability is a new-ish feature, and the documentation about this is sparse [1]. Honestly, the entire documentation about the new iCloud transfer functionality seems to be missing. Same with Game Center / GameKit. While the docs say that it should work, I'd like to understand the process in more detail.
Has anyone migrated an iCloud KVS app? What happens after the transfer goes through, but before the first release? Do I need to do anything special? I see that the Entitlements file has the TeamID in the Key Value store - is that fine?
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
Can someone please share their experience?
Thank you!
[1] https://developer.apple.com/help/app-store-connect/transfer-an-app/overview-of-app-transfer
We are using apple unity plugin (gamekit) to authorized player using game center account. To get player the info we run a task from the plugin,
var fetchItemsResponse = await GKLocalPlayer.Local.FetchItems();
But when this code run, there is an error on the xcode application on mac. The error is the following,
Thread 1: EXC_BAD_ACCESS (code=257, address=0x2)
Hello!
Bare with me here, as there is a lot to explain!
I am working on implementing a Game Center high score leaderboard into my game. I have looked around for examples of how to properly implement this code, but have come up short on finding much material. Therefore, I have tried implementing it myself based off information I found on apples documentation.
Long story short, I am getting success printed when I update my score, but no scores are actually being posted (or at-least no scores are showing up on the Game Center leaderboard when opened).
Before I show the code, one thing I have questioned is the fact that this game is still in development. In AppStoreConnect, the status of the leaderboard is "Not Live". Does this affect scores being posted?
Onto the code. I have created a GameCenter class which handles getting the leaderboards and posting scores to a specific leaderboard. I will post the code in whole, and will discuss below what is happening.
PLEASE VIEW ATTACHED TEXT TO SEE THE GAMECENTER CLASS!
GameCenter class - https://developer.apple.com/forums/content/attachment/0dd6dca8-8131-44c8-b928-77b3578bd970
In a different GameScene, once the game is over, I request to post a new high score to Game Center with this line of code:
GameCenter.shared.submitScore(id: GameCenterLeaderboards.HighScore.rawValue)
Now onto the logic of my code. For the longest time I struggled to figure out how to submit a score. I figured out that in Xcode 12, they deprecated a lot of functions that previously worked for me. Not is seems that we have to load all leaderboards (or the ones we want). That is the purpose behind the leaderboards private variable in the Game Center class.
On the start up of the app, I call authenticate player. Once this callback is reached, I call loadLeaderboards which will load the leaderboards for each string id in an enum that I have elsewhere. Each of these leaderboards will be created as a Leaderboard object, and saved in the private leaderboard array. This is so I have access to these leaderboards later when I want to submit a score.
Once the game is over, I am calling submitScore with the leaderboard id I want to post to. Right now, I only have a high score, but in the future I may add a parameter to this with the value so it works for other leaderboards as well. Therefore, no value is passed in since I am pulling from local storage which holds the high score.
submitScore will get the leaderboard from the private leaderboard array that has the same id as the one passed in. Once I get the correct leaderboard, I submit a score to that leaderboard. Once the callback is hit, I receive the output "Successfully submitted score to leaderboard". This looks promising, except for the fact that no score is actually posted.
At startup, I am calling updatePlayerHighScore, which is not complete - but for the purpose of my point, retrieves the high score of the player from the leaderboard and is printing it out to the console. It is printing out (0), meaning that no score was posted.
The last thing I have questions about is the context when submitting a score. According to the documentation, this seems to just be metadata that GameCenter does not care about, but rather something the developer can use. Therefore, I think I can cross this off as causing the problem.
I believe I implemented this correctly, but for some reason, nothing is posting to the leaderboard. This was ALOT, but I wanted to make sure I got all my thoughts down.
Any help on why this is NOT posting would be awesome! Thanks so much!
Mark
I am generating an SKTexture with a GKNoiseMap. When I look at the texture in a swift playground, it has the expected colours. But when I apply the texture to a material and render it in a SCNView, the colours are different (colours appear too bright). What am I doing wrong?
Swift playground to reproduce the issue (look at the texture variable in the playground and compare to rendered image). - https://developer.apple.com/forums/content/attachment/68210adc-98e9-4984-bca7-01f6e658d555