相关疑难解决方法(0)

GKMatchmaker findMatchForRequest邀请从未收到过

我正在尝试邀请附近的玩家参加比赛,但邀请函要么从未发送过,要么从未收到过.

GKMatchMaker startBrowsingForNearbyPlayersWithHandler工作并返回相同wifi上的附近玩家,但之后我使用findMatchForRequest并返回没有任何玩家的匹配,我尝试邀请的玩家永远不会收到邀请通知.这是我的代码.

我首先验证本地播放器:

GKLocalPlayer.localPlayer.authenticateHandler= ^(UIViewController *controller, NSError *error)
{
    if (error)
    {
        NSLog(@"%s:: Error authenticating: %@", __PRETTY_FUNCTION__, error.localizedDescription);
        return;
    }
    if(controller)
    {
        // User has not yet authenticated
        [pViewController presentViewController:controller animated:YES completion:^(void)
         {
             [self lookForNearbyPlayers];
         }];
        return;
    }
    [self lookForNearbyPlayers];
};

-(void)lookForNearbyPlayers
{
    if(!GKLocalPlayer.localPlayer.authenticated)
    {
        NSLog(@"%s:: User not authenticated", __PRETTY_FUNCTION__);
        return;
    }
Run Code Online (Sandbox Code Playgroud)

我将我的视图控制器注册为GKLocalPlayerListener的委托:

    [GKLocalPlayer.localPlayer registerListener:self]; // self is a view controller.

    // This works. My test local player which is a second device and appleID I setup shows up …
Run Code Online (Sandbox Code Playgroud)

objective-c gamekit ios game-center ios9

5
推荐指数
1
解决办法
388
查看次数

标签 统计

game-center ×1

gamekit ×1

ios ×1

ios9 ×1

objective-c ×1