endTurnWithNextParticipants is not triggering notifications.

I am serialising my game state and sending it off with endTurnWithNextParticipants.

The call returns with no errors.

And if I reload the app, the game state has indeed updated. The data is reaching GameCenter and being picked up by the next player.

So far, so good.


However I would expect.

a) an immediate push notication to appear if the game is not running

b) a player (receivedTurnEventForMatch to be called if the game is running.

Neither is happening.


I have checked...

ITC - to make sure the app is marked as GameCenter enabled.

ITC - checked the bundle name etc.

Added Push Notification entitlement in XCode (although not sure whether this is required)

Checked other game center turn apps (Letterpress) with the same IDs to make sure the IDs are valid.


Any suggestions?

Replies

Hi,

it sounds like you're having the same issue I described here:

https://forums.developer.apple.com/thread/22789


The only additional info I can give is that, of all the 3 bundle ids I've created, there is one (incidentally, the very first on which I've ever activated game center) that is fully functional. Same project, on one bundle id it works, on the others it doesn't deliver notifications or events, therefore it's definitely not a code issue.


I don't know if that can help you but please, keep us updated if you have any news.


Btw, push notification entitlement should not be necessary for GC. Not sure if it may cause a metadata rejection in case you sort out your issue but leave it enabled.

Yep.

That sounds the same.


As far as I can tell, Game Center had decided to censor the app, and although it will update the game state, it certainly will not send any notifications.

I'll post a radar. Just in case.

Still, I'm wondering if it may have to do with GC not allowing you to properly test turn based matches on more than one unreleased app.

It sounds crazy, and surely I'm hesitant to disable GC on the only testable bundle id just to try, but it's the only logical explanation I can think of. Could this apply to your case too?

In iTunes Connect, I have only one turn-based game. So it can't be that.

I wish I could **** the entire app identity, along with the provisioning profile and start again from scratch. But apparently, that is not possible.

I find this super frustrating because so much of the engineering is hidden from view. So I cannot reason about why it does not work.

Not sure if that would help. I did try creating a new app id specifically to test a fresh provisioning profile, but it still had the same issues.

That's when I threw my hands up and decided I'll have to do without listeners. Still, not having push notifications is a huge drawback.

This functionality really should work.


And given there is no API which says "UpdateGameStateButDontNotifyAnyone" - there must be something bizarre happening at the server side.


I suddenly thought perhaps I was using stale GKTurnBasedParticpant objects. (Caching them, rather than getting them fresh from the Match object) - but that wasn't the reason either.

Well there definitely seems to be some caching going on.

Indeed, one of the issues I'm having is that, if I want to get the updated match data on the inactive side, I must call loadMatchDataWithCompletionHandler:.

If I simply call

loadMatchesWithCompletionHandler:
or loadMatchWithID:withCompletionHandler:, turns and match state are updated as expected, but match data remains the last that had been sent from local side (i.e., the latest local endTurnWithNextParticipants:turnTimeout:matchData:completionHandler: or saveCurrentTurnWithMatchData:completionHandler:). This is true even after closing the app and opening it again, as if GC was always reading a locally cached data. Overall, each player gets the impressions that he's playing alone, with the other player(s) passing the turn without having done anything.


Now, while this might as well be intentional, it's also true that loadMatchData is not mandatory when I use my working bundle id. In that case, loadMatchWithID updates everything, including match data. In my mind, this is just another proof that something is going wrong with server communication.

I know that they did away with sandbox accounts, so I thought maybe there was a server-side issue from the merge.

As I understand it, there was a different sandbox server to handle beta games, and using special accounts.

This has been removed and there should be just one big happy game-center server. It should not matter how the player logs into game center.


But it looks like some new game titles are being treated as in "special measures". As far as I can tell, older published titles have full GC notifications working, but some new apps seem to be in a halfway-house state , where the game state is being stored and transmitted, but the push notifications are never being sent.

Currently I am doing a repeated "read game state" every few moments, to spot changes and simulate a push event.


Also..


Occasionally I see...

  • An message from the server on sending state - but the server state has in-fact been changed.
  • Game center reflecting a different state on both ends. So game center itself is confused about which player has the next turn. This suggests again that there is something odd going on with the server.


I wondered if there was something about the AppleIDs being used. Whether older IDs behaved differently from newer ones. But I can't see any evidence of that.

Carniphage wrote:

But it looks like some new game titles are being treated as in "special measures". As far as I can tell, older published titles have full GC notifications working, but some new apps seem to be in a halfway-house state , where the game state is being stored and transmitted, but the push notifications are never being sent.

I'm not sure what's happening in your case, but what you describe above sounds similar or related to what I'm seeing. I just released an app update, and what I'm finding is that turn-based push notifications are not working correctly for matches that were created using the previous version of the app (before the update). But if I create a new turn-based match using the latest update, then push notifications work correctly. I submitted a bug report but haven't heard anything back yet. My post about it is here:


https://forums.developer.apple.com/thread/23885

I think you’re both right in blaming Apple server transition, and I’m glad that we’re finally tracking down the source of the issue.

In my experience, Bundle Ids that have registered on the Turn Based (TB) GC server at least once before sandbox switch-off are working properly. All the other ones are not receiving notifications.

The Bundle Id creation date doesn’t matter, neither does the date in which GC was enabled or when and if the app went live.

In my case, I have a Bundle Id that I created in July, went live in August, and received a GC update (for leaderboards) in August. I only recently tried using it for TB matches, and notifications are not working, game state seems to be cached locally, etc., as describerd by Carniphage. The same goes for any newly created Id.

I also have a test Bundle Id that I created in August and never went live. I’ve been using it for a TB test project since September, and it always worked and still works correctly. I wish there was an official statement from Apple on this issue, and possibily a timeframe for bug resolution.


Since I’ve read that the TB framework has been having issues with notifications and events basically starting with iOS 7, I wouldn’t take anything for granted, and I’m now considering third-party alternatives. Having some info from Apple would surely help the assessment.

That's really interesting.


I am guessing that somewhere in the app metadata there is an item which enables or disables push notifications.

But iTunes Connect does not expose this item.


Perhaps it has somethign to do with the ghost of sandboxing.

From https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html

"In a turn-based match, the players are added to the match immediately, but a player is sent an invitation to join the match only when it becomes that player’s turn."

Maybe it's that specific functionality that does not work. It differs from the other invite functionality.

No, its not that.

The invite is arriving. The match is starting, the turn sequence is being exchanged.

It's just there are never any push notifications.