4

Thanks to the updates to GameKit API in iOS 6, I am finally able to implement my turn-based board game the way it should be, complete with turn timeouts and better programmatic creation of matches. However, I am running into an issue that I cannot seem to solve. My desire is to have Game Center running entirely invisible to the end-user, so that everything is programmatic and uses my own custom interfaces.

Therefore, I use my own custom table view to display matches, not the default GKTurnBasedMatchmakerViewController. Right now, I have no problem displaying open matches using the -loadMatchesWithCompletionHandler: method. I also use a custom screen to create a match, with a direct creation for auto-match (not a problem) and a table view that loads Game Center friends of the localPlayer for invitation. Since the playersToInvite attribute can now be filled with playerID's, this is possible in iOS 6.

My main problem is handling the invitation on the recipient's side. Lets say I invite Bob to play my game in a two-player match. Right now I can't seem to find a notification for a new invite on Bob's end. The -handleTurnEvent: only gets called for existing matches or if the banner notification is touched (which I can't guarantee the user will do), and -handleInviteFromGameCenter: does nothing for me in this case.

The only way I have come up with to detect new invites and thus update my custom game view controller is to call the -loadMatchesWithCompletionHandler: method and check for new matches in which lastTurnDate of the invited participant is nil and against an existing array of open matches. I run this check about every 10 seconds in the background since I can't find a notification in GKTurnBasedEventHandler that is called when a new invite is received. Please help!

EDIT: In the end, I have just implemented a pull-to-refresh functionality. There is no way without implementing polling or some other method that would just waste the user's data on their phone, so on demand refreshing is the most ideal solution in my opinion.

Corbin87
  • 538
  • 4
  • 12
  • Having the same problem, for what it's worth, and I haven't come up with any solution better than yours. – Andrew Plotkin Nov 24 '12 at 22:14
  • None the less, thanks for the feedback. I still haven't found a great solution for this. I have noticed that Letterpress, a new game that effectively uses a lot of the new iOS 6 API, also has this issue. It can't detect and create a match on the receiver's end when the "You received an invitation" banner pops up from Game Center. This is very frustrating and a huge oversight if there truly is no way of detecting a new match programmatically - aside from my hack above. – Corbin87 Nov 25 '12 at 19:44

1 Answers1

0

Please see this : GKInvite Reference and more specifically inviteHandler.

You just need to register an inviteHandler which will be called after Bob accepts the invite in GK/GC.

T.

tomdemuyt
  • 4,572
  • 2
  • 31
  • 60
  • 2
    I have tried using the inviteHandler, but I am fairly sure it is not applicable to a GKTurnBasedMatch. As the reference docs state: Your block should respond to the invitation in one of two ways: Display the standard user interface by initializing a new GKMatchmakerViewController object, passing the invitation object and the list of player identifiers as parameters. Create a match programmatically by calling the matchForInvite:completionHandler: method on the shared matchmaker instance. The problem is matchForInvite: takes a GKMatch, NOT a GKTurnBasedMatch, making it useless. Am I right? – Corbin87 Oct 15 '12 at 01:00
  • Plz check my question http://stackoverflow.com/questions/16266089/gkmatchrequest-invitation-not-showing-in-other-device , I dont understand why I am not getting the notification in the otehr device. Could be the issu related with handleInviteFromGameCenter or GKTurnBasedEventHandlerDelegate?? – Aitul Apr 30 '13 at 15:40