リアルタイム マッチ ゲームを作成していますが、ゲームへの招待の処理方法がわかりません。たとえば、あるデバイスのプレーヤーが友人を試合に招待すると、招待バナーが友人のデバイスに表示されます。バナーをタップして、招待を受け入れることができます。現在、友人が以前にアプリを実行し、以下の招待ハンドラー (アプリの 2 番目のビュー コントローラーにインストールされている) をインストールしている場合、これは正常に機能します。
- (void) installInvitationHandler
{
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {
// Insert game-specific code here to clean up any game in progress.
if (acceptedInvite)
{
if(self.myConnectingVC) return;
else if(self.myMatchmakerVC)
{
[self dismissViewControllerAnimated:YES completion:^{
self.myMatchmakerVC = nil;
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite];
mmvc.matchmakerDelegate = self;
self.myConnectingVC = mmvc;
[self presentViewController:mmvc animated:YES completion:nil];
}];
}
else
{
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite];
mmvc.matchmakerDelegate = self;
[self presentViewController:mmvc animated:YES completion:nil];
}
}
else if (playersToInvite)
{
[self createMatchWithPlayersToInvite:playersToInvite];
}
};
}
The problem is, what do I do if the friend has never run the app before or if the friend has not progressed far enough in the app to reach the installInvitationHandler
method? If this happens, if the friend taps on the invitation banner, the app will open but it will not accept the invitation.