GKMatchmakerViewController failed

落花浮王杯 提交于 2020-01-25 12:23:06

问题


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!");
    }
}

回答1:


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.



来源:https://stackoverflow.com/questions/33902327/gkmatchmakerviewcontroller-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!