简体   繁体   中英

GKMatchmakerViewController failed

In my app, I can see data for Leaderboards and Achievements that I have created using iTunesConnect. I can use GKTurnBasedMatchmakerViewController with no problem. But if I use GKMatchmakerViewController , immediately after selected a friend to invite, the GKMatchmakerViewController comes back with a "failed" indication (see image).

That was not all. If I use another bundle id (one that already on AppStore) just to test, then GKMatchmakerViewController will work on this app.

I have also tried to create new profile/bundle id, app id, etc. But the problem persists.

Any suggestions?

Edit: Neither connectionWithPlayerFailed nor didFailWithError method was called when it failed.

Edit 2:

This messages showed up in device logs:

Unable to bootstrap_look_up port with name com.apple.GameCenterUI.GameCenterMatchmakerExtension.gsEvents: unknown error code (1102) Failed to set com.apple.GameCenterUI.GameCenterMatchmakerExtension as keyboard focus

Edit 3: The "Play Now" (Auto-match) works fine.

在此处输入图片说明

Edit: code used

- (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers
                 viewController:(UIViewController *)viewController
                       delegate:(id<GameKitHelperDelegate>)delegate {

    if (!_enableGameCenter) return;
    MyNSLogSys;
    _matchStarted = NO;
    self.match = nil;
    _delegate = delegate;
//    [viewController dismissViewControllerAnimated:NO completion:nil];
    GKMatchRequest *request = [[GKMatchRequest alloc] init];
    request.minPlayers = minPlayers;
    request.maxPlayers = maxPlayers;

    GKMatchmakerViewController *mmvc =
    [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
    mmvc.matchmakerDelegate = self;

    [viewController presentViewController:mmvc animated:YES completion:nil];

}

// The user has cancelled matchmaking
- (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController *)viewController {
    [viewController dismissViewControllerAnimated:YES completion:nil];
}

// Matchmaking has failed with an error
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error {
    [viewController dismissViewControllerAnimated:YES completion:nil];
    NSLog(@"Error finding match: %@", error.localizedDescription);
}

// A peer-to-peer match has been found, the game should start
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match {
    [viewController dismissViewControllerAnimated:YES completion:nil];
    self.match = match;
    match.delegate = self;
    if (!_matchStarted && match.expectedPlayerCount == 0) {
        NSLog(@"Ready to start match!");
    }
}

I have seen this before. The way around it is to become friends through the game center. After that, the invites should work.

Furthermore, in iOS9, there is no longer a sandbox. So, if you are trying to connect using a debug version of your app, the notification will open game center and app store rather than going directly to your app. You can get around this simply by running in release mode instead of debug mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM