Create apps that allow players to interact with each other using GameKit.

GameKit Documentation

Posts under GameKit tag

73 Posts
Sort by:
Post not yet marked as solved
0 Replies
155 Views
I've found an issue that seems to be present across multiple titles i've tried so far. On macOS, launch a game without a game center Open the GameCenter Access Point overlay (or wait for an auto sign in prompt) Choose "Sign in with another account" Enter a valid AppleID email address Enter an incorrect password so the login fails The GC prompt then locks up, the password field can't be edited and the pop-up cannot be closed. Pressing cmd+Q does not close the application This occurs on multiple systems running macOS 12.3 but not on a system with macOS 11.3 Anyone else experienced this and found a workaround, or is the Gamecenter login just broken?
Posted Last updated
.
Post not yet marked as solved
1 Replies
202 Views
Is it possible to set an achievement progress to numbers like 0.5% or 50.1%? The fact that achievement progress is reported via a double suggests that it should be possible, but when I try doing it only the integer part seems to be saved.
Posted Last updated
.
Post not yet marked as solved
1 Replies
571 Views
Rovio is harming the Game Center by banning legitimate players in Angry Birds 2. Are you going to do anything about this?
Posted Last updated
.
Post not yet marked as solved
1 Replies
249 Views
So i downloaded the new version of ios 15.4 and it seems my gamecenter doesn‘t work. If i go to settings than gamecenter it says conection failed or there is a problem and than it forces me to go out of gamecenter. Apple please fix this i have a lot of apps that are connectet with gamecenter and i dont want to lose all the progress and the money i have spent.
Posted Last updated
.
Post not yet marked as solved
20 Replies
7.5k Views
I watched the video on Game Center Player Identifiers and saw that GKPlayer's playerId is deprecated in iOS 13, to be replaced with gamePlayerId and teamPlayerId. https://developer.apple.com/videos/play/wwdc2019/615/Our games allow players to login with Game Center to join and play games hosted on our servers. We use playerId to identify players so that they can play and earn rating points under their own account. The video says to transition to using teamPlayerId to identify players, which by itself isn't too complicated, but I'm concerned that this hasn't been fully thought through and some players may lose access to their accounts in systems like ours.1. As player's login during the transition period, we will need to read both playerId and teamPlayerId in order to change their account on our servers to the new id. After the transition, when playerId is removed from iOS, it seems that any player who hasn't logged in, perhaps returning to the app after a long break, will no longer be able to access their previous account. They will appear to us as a completely new player. It seems we need some proactive way, like a server API, to convert playerId values to the new teamPlayerId.2. In the video, the presenter says that there is a "very rare case" when teamPlayerId and gamePlayerId will not be available to uniquely identify the player. In this case, we will have no method of identifying the player and allowing them to access an account on our servers. Nothing is explained about what this "very rare case" is or how to help users correct this. Slide 13 shows how to check for the error case, but does not provide any example error message or error handling.3. We use GKLocalPlayer's generateIdentityVerificationSignatureWithCompletionHandler API to authenticate players on our servers. This API has not been updated, and it's documentation still says to use playerId. It seems a new API will be needed to deal with players having multiple, different ids.I'm interested to hear from other developers who use Game Center as a login method for their own servers and are facing these kinds of issues. I'm hoping this post might get the attention of someone at Apple, but I'll also try to engage them in other ways and report anything I find out.
Posted
by RajDoshi.
Last updated
.
Post not yet marked as solved
0 Replies
288 Views
I only started developing with Swift last week but I already made a simple game and published it on the App Store. However, I would love to add a global leaderboard for the highest scores that players get. I already have a local high score ready to be used, I just need to submit it to the leaderboard (which I set up on App Store Connect) and display the leaderboard. I only use SwiftUI in my project as it seems to be the new standard going forward, therefore I am not very familiar with how Storyboard functions. All the examples for displaying the leaderboard are done with Storyboard and I have tried for hours to make a version that works for my project but couldn't figure it out. Can anyone help me by showing me an example of how to show the leaderboard using SwiftUI Views only? Here is my code, I am able to authenticate the player on Game Center but don't know how to make a function (or View) that displays the leaderboard. I use viewState to determine which View to display in another file. Each View is stored in a separate file. I can make a LeaderboardView file if it's needed for this purpose. import SwiftUI import GameKit let localPlayer: GKLocalPlayer = GKLocalPlayer.local struct ScoreView: View {       @Binding var viewState:String   @Binding var highestScoreString:String       var body: some View {     VStack{       Spacer()               Text("HIGHEST SCORE:")       Text(highestScoreString)       Spacer()               Button(action: { let highestScore = Int(highestScoreString)         authenticatePlayer() // submit highest score here         // show leaderboard here       }){         Text("LEADERBOARD")       }               Button(action: {         viewState = "main"       }){         Text("MAIN MENU")       }               Spacer()             }   } } func authenticatePlayer() {   localPlayer.authenticateHandler = {(vc, error) -> Void in     guard error == nil else{       print(error?.localizedDescription ?? "")       return     }     GKAccessPoint.shared.isActive = localPlayer.isAuthenticated   } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
250 Views
I'm trying to add GameKit support to my TodayWidget i make GKLocalPlayer.local.authenticateHandler but got error  [Account Error] startAuthenticationForExistingPrimaryPlayer:Failed to Authenticate player.Error: Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognized by Game Center." UserInfo={NSLocalizedDescription=The requested operation could not be completed because this application is not recognized by Game Center.} When i try do same request in Host App - it complete without any error. Any suggestion? Thanks
Posted
by DimasSup.
Last updated
.
Post not yet marked as solved
2 Replies
359 Views
We're implementing multiplayer using GameKit's realtime match functionality and are seeing a certificate error on certain iOS devices when attempting to call GKMatchRequest. The request fails with the exception: "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “init.gc.apple.com” which could put your confidential information at risk." This only appears to affect a small number of iOS devices, namely: iPad 6 on iOS 14.8 iPad Mini 6th gen iPad Mini 5th gen Other iOS devices and other platforms match without issues. We've tried multiple different wifi networks on these devices (including cellular hotspot) to try to rule out local network issues. Has anyone run into this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
234 Views
I have saved games being implemented in iCloud via GameKit code in my app. It has been working correctly for months. However, I recently encountered an issue with saved game conflicts. The 'conflict detected' callback of GameKit is being triggered. I am trying to properly handle this, but it's not working. This is what I am currently doing: Receive the callback I am passed 2 saved game instances I chose the instance with the newest modification time stamp I call GameKitLoad with that chosen saved game instance I successfully receive a byte[] of data loaded from the saved game instance I then call GameKitResolveConflicts with the following parameters --- Param 1: the original array of 2 saved game instances --- Param 2: the byte[] received after loading the newest instance --- Param 3: my callback I also verify that the parameters I am passing are non-null, non-zero-length, and have valid data However, I get the following error printed out to my log "The requested operations could not be completed because one or more parameters are invalid." And then my callback is invoked with a 'false' result status. From this point on, all iCloud functions fail and saving / loading is impossible. I am unsure what is wrong, but any assistance is greatly appreciated. Thank you for your time
Posted
by LBloom.
Last updated
.
Post not yet marked as solved
0 Replies
381 Views
So I have access to the conflicting save games. I go through the save games and then pick the one with the most current time and load it. Now my question is when calling resolveConflictingSavedGames. It requires a conflictingSavedGames array that includes all the conflicting save games. Do I include ALL the conflicting save games I found including the one I just loaded with the most recent time? Also in the resolveConflictingSavedGames completion handler what exactly do I do? Do I just check for errors and nothing else? Thank you for any help I can get!
Posted
by vspyder.
Last updated
.
Post not yet marked as solved
0 Replies
483 Views
I've integrated cloud saves into my game and they work perfectly when a single device is involved. However, if I modify a save on another device then attempting to continue the save on the original device fails in GKSavedGame.loadData. Generally it fails with an error ofThe requested operations could not be completed because one or more parameters are invalid.Ocassionally I get the error that "<filename>.bundle doesn't exist" as well. I fetch the saves through `fetchSavedGames` and then resolve any conflicts by choosing the save with the most recent modification data, loading its data and then calling `resolveConflictingSavedGames'. However, I'm not actually getting any conflicts when the above error happens. Additionally, my saves actually consist of several files which need to be loaded. However, which file fails seems to be random.This is my loading code. I'm calling this function from C#, hence the code to deal with marshaling data.@_cdecl("_gameKitSavedGameLoadData") func _gameKitSavedGameLoadData(handle: UInt, csave: CSGKSavedGame) { let save = Unmanaged.fromOpaque(csave).takeUnretainedValue() save.loadData { data, err in if err != nil { let errString = "_gameKitSavedGameLoadData: for \(save.name ?? "")" + err!.localizedDescription errString.withCString { ptr in SaveCallbacks.loadSavedGameDataFailure?(handle, ptr) } return } let buffer = UnsafeMutablePointer.allocate(capacity: data!.count) data!.copyBytes(to: buffer, count: data!.count) SaveCallbacks.loadSavedGameDataSuccess?(handle, buffer, data!.count) } }The error about paramaters being invalid strikes me as particularly odd given that the only parameter that `GKSavedGame.loadData` has is a closure that is getting invoked and can't be invalid. I've also looked at the documentation and haven't seen any reference to the possibility of the GKSavedGame object being invalid. I thought that it could be my marshaling code as well, but the GKSavedGame object that this code deals with looks exactly as I expect it to. It has a vaild name, device name and modification date.
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.5k Views
I'm trying to implement Game Center in a SpriteKit game I am working on.Leaderboards started working easily, but all the tutorials I could find online are either written in objc or are from 2015 or earlier I am using Swift 5 and Xcode 11.5. The achievements are set up on App Store Connect and everything works properly, except the achievements do not load and aren't getting marked as completed. Most of my Game Center code is in the GameScene.swift file, but the Game Center page is shown with the GameViewController file.Here is my main Game Center code.// MARK: Game Center func authenticateLocalPlayer() { let localPlayer: GKLocalPlayer = GKLocalPlayer.local localPlayer.authenticateHandler = {(ViewController, error) -> Void in if((ViewController) != nil) { // 1. Show login if player is not logged in GVC.present(ViewController!, animated: true, completion: nil) } else if (localPlayer.isAuthenticated) { // 2. Player is already authenticated & logged in, load game center self.gcEnabled = true // Get the default leaderboard ID localPlayer.loadDefaultLeaderboardIdentifier(completionHandler: { (leaderboardIdentifer, error) in if error != nil { print(error as Any) } else { self.gcDefaultLeaderBoard = leaderboardIdentifer! } }) } else { // 3. Game center is not enabled on the users device self.gcEnabled = false print("Local player could not be authenticated!") print(error as Any) } } } func addPoints(pts: Int64) { // Add a point. score += pts // Submit score to Game Center leaderboard let bestScoreInt = GKScore(leaderboardIdentifier: LEADERBOARD_ID) bestScoreInt.value = score GKScore.report([bestScoreInt]) { (error) in if error != nil { print(error!.localizedDescription) } else { print("Best Score submitted to the leaderboard!") } } } func reportAchievements() { print(achievements) guard gcEnabled else { print("Game Center Not Enabled") return } GKAchievement.report(achievements) { error in guard error == nil else { print(""" GKAchievement Error: \(error as Any) """) return } } } var gcAchievements:[String:GKAchievement]? = nil func loadAchievements() { var allAchievements = [GKAchievement]() GKAchievement.loadAchievements(completionHandler: { (allAchievements, error: Error?) -> Void in if error != nil { print("Game Center: could not load achievements, error: \(String(describing: error))") } else { for anAchievement in allAchievements! { if let oneAchievement = anAchievement as? GKAchievement { self.gcAchievements?[oneAchievement.identifier] = oneAchievement } } } }) }This is called from elsewhere in GameScene.swift as:achievements = [] achievements.append(AchievementName) print(achievements) print(AchievementName.isCompleted) if A_leaveNosund.percentComplete == 0 { print("Rewarding for achievement completion...") A_leaveNosund.percentComplete = 100 reportAchievements() addPoints(pts: 1) }(AchievementName represents my achievement's name, and is declared in the same class, earlier in the file).Does anyone know what needs to be modified to make achievements load and get marked as completed in Swift 5?Any help would be appreciated.Thanks,ajldev
Posted
by ajldev.
Last updated
.
Post marked as solved
4 Replies
466 Views
When authenticating the GKLocalPlayer.localPlayer with Game Center the console logs a message: _authenticateUsingAlert:Failed to authenticate player with existing credentials.Error: Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognised by Game Center." UserInfo={GKServerStatusCode=5019, NSLocalizedDescription=The requested operation could not be completed because this application is not recognised by Game Center., NSUnderlyingError=0x600001fc57a0 {Error Domain=GKServerErrorDomain Code=5019 "status = 5019, no game matching descriptor: ios:***.***.***:1.4:4+-1" UserInfo={GKServerStatusCode=5019, NSLocalizedFailureReason=status = 5019, no game matching descriptor: ios:***.***.***:1.4:4+-1}}} After this, I CAN access the player properties such as avatar and name, but Game Center will not show any leaderboards or achievements, nor can scores be submitted. iOS 15.2, on any device or Simulator the same happens. I have tried EVERYTHING I could find on the web: check correct bundle ID create a leaderboard in App Store Connect create an achievement in App Store Connect create a whole new app in App Store Connect create a whole new project in Xcode delete and re-add Game Center capability use a different Apple ID to sign in to Game Center use a different Apple Developer Account and do the above again I do have two other games in which everything works fine. In many old posts about this, no one ever got any answer or solution, so I am thinking Apple's backend system is buggy. If anyone has ANY information on how to solve, please help.
Posted
by Wizfinger.
Last updated
.
Post marked as solved
8 Replies
985 Views
Hi all, I'm working on my first game, and the first step of getting the authenticator view is not working. To simplify the problem, I made a brand new app which only has the following code in the main view controller: import GameKit class ViewController: UIViewController {     override func viewDidLoad() {         super.viewDidLoad()         GKLocalPlayer.local.authenticateHandler = { viewController, error in             NSLog("GameKit authenticating")             if let vc = viewController {                 NSLog("IT WORKED! \(vc.description)")             } else {                 NSLog(error!.localizedDescription)             }         }     } } I've looked through older, similar issues, and so I made sure that I'd done the following: Game center is enabled in the app's Capabilities in Xcode. I've created an app associated with the bundle ID in App Store Connect. In the app's Services tab, I've created two leader boards, one "classic single". Also in Services, I've created one achievement. In the app's "prepare for submission" panel, I've turned on gamecenter, linked the leaderboards, and linked the achievement. For this test app, I have not yet uploaded a build, but I did do so on the actual game app, and and that didn't fix it. And with all that done, in my logs, it looks like this: 2022-01-16 16:28:01.582366-0800 test1ofgamecenter[6863:1006170] [Account Error] startAuthenticationForExistingPrimaryPlayer:Failed to Authenticate player.Error: Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognized by Game Center." UserInfo={NSLocalizedDescription=The requested operation could not be completed because this application is not recognized by Game Center.} 2022-01-16 16:28:01.976807-0800 test1ofgamecenter[6863:1006170] GameKit authenticating 2022-01-16 16:28:01.976988-0800 test1ofgamecenter[6863:1006170] The requested operation could not be completed because this application is not recognized by Game Center.``` I notice that my achievements and leaderboard are not "live" and I presume that is because I have not submitted the app for review, but I want to get it working before I submit a build that I would expect and want to be rejected. Is there anything else I need to do? Does this configuration require human intervention by Apple staff members? I started this phase of the development Friday evening, so I guess it'd make sense if waiting until Monday would fix it, but that seems weird. Any help? Vital Stats: - M1 Macbook Air - Xcode 13.2.1 (13C100) - Macos Monterey 12.1 - Testing on an iPhone XR and a 2021 iPad Mini, both with the most recent updates of their respective OS's
Posted Last updated
.
Post not yet marked as solved
3 Replies
677 Views
Hi,does anyone know if it is possible to use leaderboards in an imessage only game?I have created leaderboards and they are live with my app. But nevertheless on authentication I always get:[Error] _authenticateUsingAlert:Failed to authenticate player with existing credentials.Error: Error Domain=GKErrorDomain Code=15 "Der angeforderte Vorgang konnte nicht abgeschlossen werden, da die App vom Game Center nicht erkannt wird." UserInfo={GKServerStatusCode=5019, NSLocalizedDescription=Der angeforderte Vorgang konnte nicht abgeschlossen werden, da die App vom Game Center nicht erkannt wird., NSUnderlyingError=0x283d36d60 {Error Domain=GKServerErrorDomain Code=5019 "status = 5019, no game matching descriptor: ios:net.mygame.MessagesExtension:1.3:1+-1" UserInfo={GKServerStatusCode=5019, NSLocalizedFailureReason=status = 5019, no game matching descriptor: ios:net.mygame.MessagesExtension:1.3:1+-1}}}Is it possible that iMessage only games are not supported by GameKit? As the iMessage App has the Bundle identifier net.mygame.MessagesExtensionand it seems the Leaderboard associated with it in the appastoreconnect interface is registered to net.mygame?Or is there something I overlooked?Thanks, Jan
Posted
by happy77.
Last updated
.
Post not yet marked as solved
4 Replies
1k Views
[Match] cannot set connecting state for players: ( "..." ), as there is no inviteDelegate set yet. The state might directly change to Ready when we set the inviteDelegate later and call sendQueuedStatesAndPackets. We are setting the match.delegate to our implementation of GKMatchDelegate and GKMatchmakerViewControllerDelegate. It also prints a warning later: [Developer] <Warning>: need to implement one of the following methods in GKMatchDelegate: match:didReceiveData:forRecipient:fromRemotePlayer:, match:didReceiveData:fromRemotePlayer: However we are certainly implementing that func: public func match(_ match: GKMatch, didReceive data: Data, forRecipient recipient: GKPlayer, fromRemotePlayer player: GKPlayer) { print("Data received from player..."); } Any ideas?
Posted Last updated
.
Post not yet marked as solved
0 Replies
333 Views
this GKAccessPoint code fails on macOS. The AccessPoint button appears, but disappears when clicked -- no modal window. works fine on iOS but not macOS. what am i doing wrong? import SwiftUI import GameKit struct AccessPoint: View { var body: some View { ZStack { Color.clear Text("GKAccessPoint") } .onAppear() { GKLocalPlayer.local.authenticateHandler = { viewController, error in GKAccessPoint.shared.isActive = true } } } }
Posted
by Fault.
Last updated
.
Post not yet marked as solved
0 Replies
412 Views
So, I am making a game using GKVoiceChat. And I want to make sure that the local player is able to participate in voice chats. So I use the .isPersonalizedCommunicationRestricted. No matter what account I uses (Sandbox or personal) the variable is always true! Im 18+. And have no restriction set on the phone/iCloud account. I know for a fact that I am authentication the player properly because I am able to start and play a multiplayer match. And also isMultiplayerGamingRestricted = false. And Ideas. If you need code just ask :)
Posted
by bhavin84.
Last updated
.