4
我遇到了邀請朋友參加比賽的困難。遊戲中心以編程方式邀請朋友
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來處理多人模式。奇怪的問題是,我也沒有在控制檯中看到任何日誌良好匹配/其他錯誤,並且僅當我調用上述代碼兩次時纔打印[錯誤描述] - 它表示以前的請求已被取消。
在此先感謝。
在iOS 6中,您現在可以執行此操作,即不再忽略playersToInvite屬性。 – sup 2013-02-24 04:30:25
@sup這是真的,但是你仍然不能以編程方式攔截使用handleInviteFromGameCenter的邀請,因爲該調用似乎只能從Game Center視圖控制器觸發。 – todd412 2013-04-04 04:11:15