游戏中心以程序方式邀请朋友 [英] Game Center inviting friends progammatically

查看:123
本文介绍了游戏中心以程序方式邀请朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难邀请朋友参加比赛。

I'm facing difficulty inviting a friend to the match.

GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; 
    request.minPlayers = 2;
    request.maxPlayers = 2;
    request.playersToInvite = [NSArray arrayWithObjects: @"G:1102359306",nil ];


//  GKMatchmakerViewController *mv = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
//  [self presentModalViewController:mv animated:YES];


    [[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
        if (error) {
            NSLog([error description]);
        }
        else if (match != nil) {NSLog(@"good match");
            //self.chatMatch = match;
            //self.chatMatch.delegate = self;       
            //[self chatReady];
        }
        else {
            NSLog(@"other error");
        }

    }];

问题是我从未收到登录该帐户的第二台设备上的邀请通知 - G:1102359306。
当我使用GKMatchmakerViewController(取消注释2行以上)并评论GKMatchmaker块时,我已经自动检查了好朋友 - G:1102359306,当我邀请他时会显示接受/拒绝的通知,这就是我知道它是正确的。

The problem is I never receive the invitation notification on second device logged to the account - G:1102359306. When I use GKMatchmakerViewController (uncomment above 2 lines) and comment GKMatchmaker block I have automatically checked the good friend - G:1102359306 and when I invites him the notification with accept/decline is shown, that's how I know it's correct.

您认为上述代码有什么问题吗?我想使用自己的UI来处理多人游戏模式。奇怪的问题是我也没有在控制台中看到任何日志匹配/其他错误,并且[错误描述]仅在我调用上述代码两次时打印 - 它表示先前的请求被取消。

Do you see anything wrong with the code above? I want to use my own UI to handle the multiplayer mode. The strange problem is I also don't see in console any logs good match/other error, and the [error description] is only printed when I call the above code twice - it says that the previous req was canceled.

提前致谢。

推荐答案

您无法以编程方式邀请一组特定的玩家参加一场比赛。 findMatchForRequest:withCompletionHandler:文档说明:

You cannot programmatically invite a specific set of players to a match. The findMatchForRequest:withCompletionHandler: documentation says this:


匹配请求的 playersToInvite 属性被忽略;要邀请特定的一组玩家参加比赛,你必须显示一个红娘视图控制器。

The match request’s playersToInvite property is ignored; to invite a specific set of players to the match, you must display a matchmaker view controller.

没有公共API可以做什么你想要的。

There is no public API that does what you want.

这篇关于游戏中心以程序方式邀请朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆