4

I'm facing difficulty inviting a friend to the match.

GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; 
    request.minPlayers = 2;
    request.maxPlayers = 2;
    request.playersToInvite = [NSArray arrayWithObjects: @"G:1102359306",nil ];


//  GKMatchmakerViewController *mv = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
//  [self presentModalViewController:mv animated:YES];


    [[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
        if (error) {
            NSLog([error description]);
        }
        else if (match != nil) {NSLog(@"good match");
            //self.chatMatch = match;
            //self.chatMatch.delegate = self;       
            //[self chatReady];
        }
        else {
            NSLog(@"other error");
        }

    }];

The problem is I never receive the invitation notification on second device logged to the account - G:1102359306. When I use GKMatchmakerViewController (uncomment above 2 lines) and comment GKMatchmaker block I have automatically checked the good friend - G:1102359306 and when I invites him the notification with accept/decline is shown, that's how I know it's correct.

Do you see anything wrong with the code above? I want to use my own UI to handle the multiplayer mode. The strange problem is I also don't see in console any logs good match/other error, and the [error description] is only printed when I call the above code twice - it says that the previous req was canceled.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Chris Rutkowski
  • 1,774
  • 1
  • 26
  • 36

1 Answers1

2

You cannot programmatically invite a specific set of players to a match. The findMatchForRequest:withCompletionHandler: documentation says this:

The match request’s playersToInvite property is ignored; to invite a specific set of players to the match, you must display a matchmaker view controller.

There is no public API that does what you want.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • In iOS 6 you can now do this, i.e. the playersToInvite property is no longer ignored. – sup Feb 24 '13 at 04:30
  • @sup that is true, however you still cannot programmatically intercept invites using handleInviteFromGameCenter as that call appear to be triggered only from the Game Center View Controllers. – todd412 Apr 04 '13 at 04:11