iOS 6 での GameKit API の更新のおかげで、ターン タイムアウトとより優れたプログラムによるマッチの作成を完了して、ターン ベースのボード ゲームを本来あるべき方法で実装できるようになりました。しかし、私は解決できないように見える問題に直面しています。私の望みは、Game Center をエンド ユーザーから完全に見えなくして実行し、すべてがプログラム化され、独自のカスタム インターフェースを使用できるようにすることです。したがって、デフォルトの GKTurnBasedMatchmakerViewController ではなく、独自のカスタム テーブル ビューを使用して一致を表示します。現在、-loadMatchesWithCompletionHandler: メソッドを使用してオープン マッチを表示しても問題ありません。また、カスタム画面を使用してマッチを作成し、自動マッチ (問題ではありません) を直接作成し、招待用に localPlayer の Game Center フレンドをロードするテーブル ビューを使用します。
私の主な問題は、受信者側で招待状を処理することです。次のコードで招待状を送信します
-(void)invitarAmigoMio:(NSArray*)losAmigos
{
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
request.defaultNumberOfPlayers=2;
request.playersToInvite = losAmigos;
request.inviteMessage = @"Your Custom Invitation Message Here";
request.inviteeResponseHandler = ^(NSString *playerID, GKInviteeResponse
response)
{
if (response==GKInviteeResponseAccepted)
{
NSLog(@"INVITACION ACEPTADA");
}
else
{
NSLog(@"INVITACION RECHAZADA");
}
};
}
通知を処理するデリゲートがあります。次のコードは、ユーザーが認証されると起動します
-(void)registroNotificaciones
{
NSLog(@"registroNotificaciones");
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite* acceptedInvite, NSArray *playersToInvite)
{
if(acceptedInvite != nil)
{
// Get a match for the invite we obtained...
[[GKMatchmaker sharedMatchmaker] matchForInvite:acceptedInvite completionHandler:^(GKMatch *match, NSError *error)
{
if(match != nil)
{
NSLog(@"match != nil: ");
}
else if(error != nil)
{
NSLog(@"ERROR: From matchForInvite: %@", [error description]);
}
else
{
NSLog(@"ERROR: Unexpected return from matchForInvite...");
}
}];
}
};
NSLog(@"FIN registroNotificaciones");
}
通知が送信されないのはなぜですか?または通知が受信されないのですか?ゲームをプレイするように招待するために通知を送信する別の方法はありますか? Game Center のサンドボックス アカウントで招待が許可されていることを確認しましたが、何が起こっているのかわかりません