Definitive answer to what playersToInvite is for

梦想的初衷 提交于 2020-01-16 04:53:28

问题


The Game Center documentation indicates that the

playersToInvite parameter is non-nil when your application is launched directly from the Game Center application to host a match.

A few people have asked how this works exactly, i.e. there doesn't appear to be a way to select a friend from the Game Center application and invite them to play from Game Center; it only works when you invite in-game. Is this documentation dated or is there a secret way to start a game-specific match from Game Center? I'd like to test my inviteHandler but I've been unable to determine how this parameter is passed to the application.

[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
{
    // clean up games in progress here
    if (acceptedInvite)
    {
        NSLog(@"acceptedInvite %@", acceptedInvite);
        // The acceptedInvite parameter is non-nil when the application receives an 
        // invitation directly from another player.
        GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
        mmvc.matchmakerDelegate = self;
        [self disableHomeUI];
        [self presentModalViewController:mmvc animated:YES];
    }
    else if (playersToInvite)
    {
        NSLog(@"playersToInvite %@", playersToInvite);
        // playersToInvite parameter is non-nil when your application is launched 
        // directly from the Game Center application to host a match
        [self disableHomeUI];
        [self doPresentMatchMakerUIWithPlayersToInvite:playersToInvite];
    }
};

回答1:


I think the docs do not reflect the current state of affairs. As far as I can tell, the Game Center App does not even offer an interface for inviting friends to play, currently.

Also, check the developer forums (apparently you have ;) ). Someone from Cupertino seems to think it is not possible. So...




回答2:


After launching my application Cee-lo into production, the playersToInvite code became active. This seems to be because the Sandbox version of the Game Center app itself does not allow you to start a game with a player from there, but the production version does. Not a very good test environment if you ask me!




回答3:


There is now a way to use the Game Center app to invite a Game Center friend. It ONLY works if your game calls registerListener: on the localPlayer GKPlayer:

Game Center App -> games tab -> your game -> Players section -> select a player -> "Play a Game"

This will send a push notification invite to the other player. Game does not have to be running on either device. As of iOS7.

This flow also works: Game Center App -> friends tab -> tap a friend -> tap a game in common (your game) -> tap the "..." in the top right corner -> tap "Play"




回答4:


I could be wrong, but i think it is just the "simulator" that can not invite particular friends to play.

I have been able to use 2 or more iPhones running in the sandbox to invite particular friends to play, and it has worked wonderfully for debugging the invite handler piece of code.

As another poster mentioned, there does not appear to be at this time a way of inviting particular friends to play a particular game from Game Center.

Happy gaming!



来源:https://stackoverflow.com/questions/3962717/definitive-answer-to-what-playerstoinvite-is-for

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