I am working with SwiftUI and Game Center to create a multiplayer game. I am having trouble presenting a the GKMatchmakerViewController after initializing it with the amount of players and invite message. I have tried using a button to call my presentMatchmaker() function but this does not work. Any help is much appreciated!
func presentMatchmaker() {
guard GKLocalPlayer.local.isAuthenticated else {
return
}
let request = GKMatchRequest()
request.minPlayers = 2
request.maxPlayers = 7
request.inviteMessage = "You have been challenged..."
guard let vco = GKMatchmakerViewController(matchRequest: request) else {
return
}
self.ViewController?.present(vco, animated:true)
}