Reputation: 18149
-(void)startMatchMakingWithDelegate:(id)_delegate {
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.defaultNumberOfPlayers = 2;
request.minPlayers = 2;
request.maxPlayers = 2;
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc]initWithMatchRequest:request];
mmvc.matchmakerDelegate = _delegate;
[gameViewController presentViewController:mmvc animated:YES completion:nil];
}
This opens a matchmaking view. In this view, there is a button for inviting friends to the match, which opens an invitation menu.
Is it possible to open this matchmaking view with the invitation menu already open by default?
For context, my game has "ranked matches" and "friendly matches". Ranked matches cost you points. If you play against a random player, then it counts as ranked, and if you play against a friend, it is a friendly match. I want to have two buttons, one labeled "ranked" and another "friendly". This is why I want a way to open the matchmaking interface with the friend invitation view by default - so I can use it for the "friendly" button.
Upvotes: 2
Views: 157
Reputation: 153
You cannot reach the screen to invite friends directly. One work around would be to use "Challenge" friend feature of game center for friendly matches. This is a good tutorial for it. Another option is to show a popup before opening the matchmaking screen to let user know about the rules of friendly and ranked matches. You will have to check the match object once the user is assigned to a match. If the user is playing after inviting a friend, the match.participants array would have an entry at index:1 AND that participant wouldn't have played turn yet (can be checked using lastTurnDate).
if([[match.participants objectAtIndex:1] playerID] && [[match.participants objectAtIndex:1] lastTurnDate])
If not, the user would be playing a ranked match with a random player.
Upvotes: 3