不推荐使用GKMatchMaker邀请处理程序 [英] GKMatchMaker invite handler deprecated

查看:64
本文介绍了不推荐使用GKMatchMaker邀请处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下用于处理邀请的代码:

I have the following code that I have been using before to handle invitations:

[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {
    // Insert game-specific code here to clean up any game in progress.
    if (acceptedInvite) {
        GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite];
        mmvc.matchmakerDelegate = self;
        [self presentViewController:mmvc animated:YES completion:nil];
    }
};

但是,现在它已在iOS 7中弃用. 我在哪里如何在我的项目中注册GameKit邀请处理程序?

However, now it has become deprecated in iOS 7. Where and how do I register a GameKit invite handler in my project?

推荐答案

GKInviteEventHandler ,特别是要查看符合GKLocalPlayerListener协议,您应该没问题.下面是协议方法,这些方法看起来像是邀请函Handler的预期替代品,但分为两部分.

Conform to the GKLocalPlayerListener protocol and you should be OK. Below are the protocol methods, which look to be the intended replacement for invitationHandler, but split up in two parts.

- (void)player:(GKPlayer *)player didAcceptInvite:(GKInvite *)invite
- (void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray *)playerIDsToInvite

设置符合该对象的对象后,只需调用registerListener:.

After you set up some object to conform to that, you just make a call to registerListener:.

[[GKLocalPlayer localPlayer] registerListener:yourObjectHere]

不用担心尽快注册,因为系统会缓存基于邀请/挑战/回合的内容,如果没有人可以处理这些内容并在设置后立即告知您的听众.

Don't worry about registering it as soon as possible, as the system caches the invites/challenges/turn based stuff, if there's no one to handle those and lets your listener know as soon as you set it up.

这篇关于不推荐使用GKMatchMaker邀请处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆