游戏中心以编程方式邀请好友
我在邀请朋友观看比赛时遇到困难。
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,当我邀请他时,会显示接受/拒绝的通知,这就是我知道它是正确的。
你看到上面的代码有什么问题吗?我想使用自己的 UI 来处理多人游戏模式。奇怪的问题是我在控制台中也没有看到任何日志良好匹配/其他错误,并且仅当我两次调用上述代码时才会打印[错误描述] - 它表示先前的请求已被取消。
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");
}
}];
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法以编程方式邀请一组特定的玩家参加比赛。
findMatchForRequest:withCompletionHandler:
文档 说:没有公共 API 可以满足您的要求。
You cannot programmatically invite a specific set of players to a match. The
findMatchForRequest:withCompletionHandler:
documentation says this:There is no public API that does what you want.