Nick Harris

Game Center Sandbox – Troubleshooting Invites – Help Wanted!

with 4 comments

I’ve been working on integrating Game Center into my game for a few months now. The Game Kit framework is fairly straightforward. The hardest part I originally found was engineering my code to be server/client friendly. This was before the dev center went down. Since then, invitations in the Game Center Sandbox have become a nightmare.

To figure out what’s going on, I created a small sample app to demonstrate the issues I’m seeing.

If you’re a Game Center expert I’d love to get your opinion. Are the following issues with my code or are they issues with the Game Center Sandbox?

If you’re looking to learn Game Center you might find this little sample app helpful with getting started since it shows how to authenticate, get game center friends, send and accept invitations to a match as well as sending simple data to players.

The Sample AppYou can get the code here (*) (**)

demoappsuccess

The app is very simple. It authenticates the local user, gets the users Game Center friends and shows them in a table, then sends invites when the user taps a friends name. Once the match is established and everyone is connected, the players send a simple string of data to each other. All of the interaction is logged to the screen so you can see what’s happening in the code.

The Issues

Issue: Invites sent from one device never show on the other.

Game Center allows you to either invite specific friends to a match or use auto-match, which looks for other players waiting to join a match. I’ve opted not to use auto-match, instead inviting one specific friend at a time. Both use a GKMatchRequest, but I supply a playerID when creating the match.

The first player gets invited using findMatchForRequest:withCompletionHandler: (which I’ll refer to as findMatch). If the invitation is processed correctly, the app will get a GKMatch in the completion handler.

Subsequent players get invited using addPlayersToMatch:matchRequest:completionHandler: (which I will refer to as addPlayer).

In the past I’d occasionally see that invites from one device would never show on another. This issue seems to have been around for quite a while with a couple troubleshooting steps to make them show up again.

First, make sure you have Game Center notifications turned on the invitee device. The push notification for the invite will never show up if they’re turned off.

Second, use the Game Center app to log out of Game Center, then launch the Sample App and let it handle re-authenticating you. In the past I would need to do this every half hour or so while testing to get invitation push notifications working again.

These steps no longer work for me.

Instead, what I’ve found with the sample app is that repeatedly adding the player to the existing match will eventually get the invite through to the other device. Usually the findMatch call fails to get the invite through but the first addPlayer does work. Additional players often need two or more calls to addPlayer to get other invites out.

addplayer

This should all work the first time. I can’t figure out why I need to repeatedly add the same player to a match to get the invite to show on the other device.

Issue: inviteeResponseHandler doesn’t get called

Before calling either findMatch or addPlayer, the GKMatchRequest’s inviteeResponseHandler is set. Once the invitee either accepts or declines the invite, the handler gets fired so the inviter knows the fate of the invite. When the invitee accepts the invite, its able to get the match.

This use to fire every time I accepted or denied an invitation. Now it’s very hit or miss.

When it doesn’t fire, the invitee’s match delegate will eventually get a match:player:didChangeState: call saying the inviter has left the match. The inviter never gets any notifications. It’s interesting that the invitee sees this when its never called for the inviter connecting to the match.

inviterdisconnected

I’ve found that if I continue to re-invite the friend repeatedly it will eventually fire the correct callbacks and get all the players connected to the match.

When this process does finally complete, the devices are able to send data back and forth with no issue for the duration of the match.

repeatforsuccess

So…

Does anyone know if this is an issue with the Sandbox or is it my code? Does Apple review apps against the Sandbox or against the production servers?

If it’s my code I can fix it. If it’s the sandbox, how to I successfully test my app before submitting it for review?

(*) You’ll need to set the Bundle ID and Code Signing to one you’ve setup with iTunes Connect in order to test.

(**) GameCenterManager class is based on Kyle Richter book “Beginning iOS Game Center and Game Kit”.

Advertisements

Written by Nick Harris

August 20, 2013 at 7:03 am

Posted in Uncategorized

4 Responses

Subscribe to comments with RSS.

  1. I and others are experiencing the exact same problem. See https://devforums.apple.com/thread/199452

    I filed a bug on 8/20 but have not received a response.

    Anonymous

    August 27, 2013 at 5:21 pm

  2. Thanks for an extremely well-informed write-up. Makes me think about making a start writing one more time.

    Whatever assistance how most effective to get planning..

    Emilie

    February 14, 2014 at 3:58 am

  3. Your web site is incredible. Could I connect
    with you on Google+?

  4. Hi! Did you fix this? Did you find a way to make it happen? I’m facing the same problem right now: I can accept the invitation, but the players state is always “Connecting”, and only after a few tries, it set to “ready” state.
    But, when everything is ready to start, most of the times the remote customers get a “disconnected”, and the game does not start.
    Well, I’ll keep googling for an answer before send it to the store. Any help would be great.
    Regards.

    Anibal Itriago

    September 4, 2014 at 2:51 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: