{"id":20439883,"url":"https://github.com/v-braun/gcconnection","last_synced_at":"2025-10-27T21:19:30.331Z","repository":{"id":96755320,"uuid":"163819958","full_name":"v-braun/GCConnection","owner":"v-braun","description":"GameCenter multiplayer connection util","archived":false,"fork":false,"pushed_at":"2019-08-26T07:24:47.000Z","size":496,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T22:43:35.215Z","etag":null,"topics":["gamecenter","gamekit","gkmatchmaker","ios","matchmaking","multiplayer-game","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/v-braun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-01-02T09:21:17.000Z","updated_at":"2021-06-04T07:42:01.000Z","dependencies_parsed_at":"2023-03-22T21:41:15.600Z","dependency_job_id":null,"html_url":"https://github.com/v-braun/GCConnection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/v-braun/GCConnection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v-braun%2FGCConnection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v-braun%2FGCConnection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v-braun%2FGCConnection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v-braun%2FGCConnection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v-braun","download_url":"https://codeload.github.com/v-braun/GCConnection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v-braun%2FGCConnection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276562598,"owners_count":25664430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-23T02:00:09.130Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gamecenter","gamekit","gkmatchmaker","ios","matchmaking","multiplayer-game","swift"],"created_at":"2024-11-15T09:20:12.916Z","updated_at":"2025-09-23T11:05:36.482Z","avatar_url":"https://github.com/v-braun.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GCConnection\r\n\u003e GameCenter multiplayer connection util\r\n\r\nBy [v-braun - viktor-braun.de](https://viktor-braun.de).\r\n\r\n[![](https://img.shields.io/github/license/v-braun/GCConnection.svg?style=flat-square)](https://github.com/v-braun/GCConnection/blob/master/LICENSE)\r\n[![Build Status](https://img.shields.io/travis/v-braun/GCConnection.svg?style=flat-square)](https://travis-ci.org/v-braun/GCConnection)\r\n![PR welcome](https://img.shields.io/badge/PR-welcome-green.svg?style=flat-square)\r\n\r\n\u003cp align=\"center\"\u003e\r\n\u003cimg width=\"70%\" src=\"https://github.com/v-braun/GCConnection/blob/master/.assets/logo.png?raw=true\" /\u003e\r\n\u003c/p\u003e\r\n\r\n\r\n## Description\r\n\r\n\r\n## Installation\r\n\r\n1. Download and drop ```GCConnection.swift``` in your project.  \r\n2. Congratulations!  \r\n\r\n\r\n## Usage\r\n\r\nFor detailed usage check out the demo [ViewController.swift](https://github.com/v-braun/GCConnection/blob/master/GCConnection/ViewController.swift) file.\r\n\r\n\r\n### Authenticate\r\n\r\nIn your AppDelegate invoke *authenticate*\r\n\r\n``` swift\r\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\r\n    \r\n    GCConnection.shared.authenticate()\r\n    \r\n    return true\r\n}\r\n```\r\n\r\nLater on in your ViewControlelr you can check the authenticate status\r\n\r\n``` swift\r\n\r\nswitch GCConnection.shared.authStatus {\r\ncase .undef:\r\n    // not authenticated\r\ncase .loginCancelled:\r\n    // login canccelled 🙅‍♀️\r\ncase .error(let err):\r\n    // auth err\r\ncase .loginRequired(let viewController):\r\n    // login required\r\n    // show present ciewController - it is the GC login view\r\ncase .ok(let localPlayer):\r\n    // authenticated 🥳\r\n}\r\n\r\n```\r\n\r\nYou can also listen to authentication state changes!\r\n\r\nImplement the *AuthHandler* protocol and set the authHandler property\r\n\r\n``` swift\r\n\r\noverride func viewDidLoad() {\r\n    super.viewDidLoad()\r\n    \r\n    GCConnection.shared.authHandler = self\r\n}\r\n\r\nextension ViewController : AuthHandler{\r\n    func handle(connection: GCConnection, authStatusChanged: AuthStatus) {\r\n        // your code ...\r\n    }\r\n}\r\n\r\n```\r\n\r\n### Match making\r\n\r\n\r\nTo create a match simply call *findMatch*.  \r\nTo listen on status updates you should set the *handler* property on the match. \r\n\r\n``` swift\r\n\r\nlet match = try! GCConnection.shared.findMatch(minPlayers: 2, maxPlayers: 2)\r\nmatch.handler = self\r\n\r\n```\r\n\r\nExample implementation of the *MatchHandler* protocol:\r\n\r\n\r\n``` swift\r\nextension ViewController : MatchHandler{\r\n    func handle(_ error: Error) {\r\n        // error \r\n    }\r\n    \r\n    func handle(_ state: MatchState) {\r\n        // status update \r\n    }\r\n    \r\n    func handle(data: Data, fromPlayer: GKPlayer) {\r\n        // received data from given player\r\n    }\r\n    \r\n    func handle(playerDisconnected: GKPlayer) {\r\n        // given player has disconnected\r\n    }\r\n}\r\n```\r\n\r\n\r\nYou can always cancel a match with  \r\n``` swift\r\nmatch.cancel()\r\n```\r\n\r\n\r\nThe active match is always accessible on the shared GCConnection instance \r\n``` swift\r\nGCConnection.shared.activeMatch\r\n```\r\n\r\n### Send data\r\n\r\nTo send data use broadCast method\r\n\r\n``` swift\r\n\r\nlet data = \"hello\".data(using: .utf8)\r\ntry! GCConnection.shared.activeMatch!.broadCast(data: data!, withMode: GKMatch.SendDataMode.reliable)\r\n\r\n```\r\n\r\n\r\n## Configuration\r\n\r\n### Prepare App for GameCenter support\r\n\r\nFirst you should enable the GameCenter feature in your ap.  \r\nGo to Project/Capabilities and enable GameCenter  \r\n![Enable GameCenter](https://github.com/v-braun/GCConnection/blob/master/.assets/enable-gc-proj.png?raw=true)\r\n\r\n\r\n\r\nAfter that you have to register your app in [App Store Connect](https://appstoreconnect.apple.com/). \r\nLogin with your account and go to **My Apps**  \r\n![App Store Connect Home](https://github.com/v-braun/GCConnection/blob/master/.assets/appstore-conn-home.png?raw=true)\r\n\r\n\r\n\r\nOn the Dashboard add a new App  \r\n![App Store Connect Dashboard](https://github.com/v-braun/GCConnection/blob/master/.assets/appstore-conn-dashboard.png?raw=true)\r\n\r\n\r\nEnter the needed information.  \r\n**IMPORTANT:** The BundleIdentifier should match your Project setting\r\n\r\n\r\nDuring my tests I found out that GameCenter will not recognize your app until you create at least one leaderboard.  \r\nGoto /Features/Game Center/Leaderboard  \r\n![App Store Connect Leaderboard](https://github.com/v-braun/GCConnection/blob/master/.assets/appstore-conn-leaderboard.png?raw=true)\r\n\r\n\r\n\r\n## Related Projects\r\n[Cocoa Rocks](https://cocoa.rocks/): a gallery of beatiful Cocoa Controls  \r\n[awesome-cocoa](https://github.com/v-braun/awesome-cocoa): an awesome list of cocoa controls\r\n\r\n\r\n## Authors\r\n\r\n![image](https://avatars3.githubusercontent.com/u/4738210?v=3\u0026amp;s=50)  \r\n[v-braun](https://github.com/v-braun/)\r\n\r\n\r\n\r\n## Contributing\r\n\r\nMake sure to read these guides before getting started:\r\n- [Contribution Guidelines](https://github.com/v-braun/GCConnection/blob/master/CONTRIBUTING.md)\r\n- [Code of Conduct](https://github.com/v-braun/GCConnection/blob/master/CODE_OF_CONDUCT.md)\r\n\r\n## License\r\n**GCConnection** is available under the MIT License. See [LICENSE](https://github.com/v-braun/GCConnection/blob/master/LICENSE) for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv-braun%2Fgcconnection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv-braun%2Fgcconnection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv-braun%2Fgcconnection/lists"}