iOS Development: When receiving a Game Center invite, how do I obtain the GKMatch object?

后端 未结 3 1567
野性不改
野性不改 2021-02-06 15:54

I\'m building an iPhone game that uses Game Center and I\'m having a hard time understanding how to start a match game that was started by receiving an invitation to play from a

3条回答
  •  北海茫月
    2021-02-06 16:47

    Despite what the Apple engineer said, how about try something like this to invite without using a custom view:

    [[GKLocalPlayer localPlayer] loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error) {
    
    
    
    [GKPlayer loadPlayersForIdentifiers:friends withCompletionHandler:^(NSArray *players, NSError *error) {
        for (GKPlayer *player in players) {
            NSLog(@"%@",player.alias); //here I'm just logging the aliases but the array players can be used in any way
        }
    }];
    

    } ];

    Now if a user selects players from this list on a custom view, GKMatchRequest has a property called playersToInvite and we can set these players to that property. And create a match programmatically using this request.

    This looks very possible but I haven't tried it to be honest

提交回复
热议问题