I am making a real time Game Center game, with GameKit as a new programmer, however I have run into a few road blocks.
I am able to properly initialize the local player, present the matchmaking viewController, and receive and accept invites, however, even after I accept the invite
I am able to properly initialize the local player, present the matchmaking viewController, and receive and accept invites, however, even after I accept the invite
Code Block matchmakerViewController:didFindMatch
is not called and no match is returned to me. There is a high likelihood that I did not accept the invitation correct, but according to apples developer forums I have. If someone could review this code and let me know how to have that method be called that'd be great!Code Block let request = GKMatchRequest() class SecondScreenViewController : UIViewController, UINavigationControllerDelegate, GKMatchmakerViewControllerDelegate, GKLocalPlayerListener { let button = UIButton() let softRed = UIColor(red: 1, green: 61 / 255, blue: 61 / 255, alpha: 1) let softblue = UIColor(red: 38 / 255, green: 149 / 255, blue: 1, alpha: 1) let TestMatchMaker = GKMatchmaker() let TestMatch = GKMatch() var TestViewController = GKMatchmakerViewController(matchRequest: request) var player = GKLocalPlayer.local override func viewDidLoad() { super.viewDidLoad() player.register(self) setupButton() SetupRequest() view.backgroundColor = softblue } func matchmakerViewControllerWasCancelled(_ viewController: GKMatchmakerViewController) { dismiss(animated: true, completion: nil) print("cancelled") } func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) { print(error.localizedDescription + "THIS IS AN ERROR FROM THE VIEWCONTROLLER") } func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) { print("Found Match Successfully") let TestMatch = match print(TestMatch) } func player(_ player: GKPlayer, didAccept invite: GKInvite) { print(invite) print("Aceppted Invite") TestViewController?.setHostedPlayer(player, didConnect: true) } func player(_ player: GKPlayer, didRequestMatchWithRecipients recipientPlayers: [GKPlayer]) { print("Requested Match") } func SetupRequest() { request.minPlayers = 2 request.maxPlayers = 2 request.inviteMessage = "test Invite" } func setupButton() { button.backgroundColor = UIColor.white button.setTitleColor(softblue, for: .normal) button.setTitle("MatchMake", for: .normal) button.addTarget(self, action: #selector(ButtonTapped), for: .touchUpInside) view.addSubview(button) setupButtonConstraints() } func setupButtonConstraints() { button.translatesAutoresizingMaskIntoConstraints = false button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30).isActive = true button.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30).isActive = true button.heightAnchor.constraint(equalToConstant: 100).isActive = true button.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0).isActive = true } @objc func ButtonTapped() { present(TestViewController!, animated: true, completion: { self.TestViewController!.delegate = self}) TestViewController?.matchmakerDelegate = self } }