gpt4 book ai didi

iphone - Game Center 以编程方式邀请好友

转载 作者:可可西里 更新时间:2023-11-01 05:59:07 26 4
gpt4 key购买 nike

我在邀请 friend 参加比赛时遇到困难。

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 block 时,我自动检查了好 friend - G:1102359306,当我邀请他时,会显示接受/拒绝的通知,这就是我知道它是正确的方式。

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

最佳答案

您不能以编程方式邀请一组特定玩家参加比赛。 findMatchForRequest:withCompletionHandler: documentation是这样说的:

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.

没有公共(public) API 可以满足您的需求。

关于iphone - Game Center 以编程方式邀请好友,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4117781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com