How do I reply to a GKTurnBasedExchange? GKLocalPlayerListener delegate receivedExchangeReplies is called intermittently
Asked Answered
O

1

3

There are a handful of posts discussing how Game Center's push notifications were fairly unreliable in the sandbox. However, the sandbox is obfuscated with iOS 9 so, I'm not sure why my Game Center push notifications are so unreliable.

When I reply to the active exchange, the sender is rarely notified.

[exchange replyWithLocalizableMessageKey:@"EXCHANGE_REPLY" arguments:@[] data:data completionHandler:^(NSError *error) {

            if (error)
            {
                NSLog(@"");
            }
        }];

On the senders device, if I refresh the match data, I'll see a pending reply. If I process the reply, everything works.

The same goes for this method:

- (void)sendExchangeToParticipants:(NSArray<GKTurnBasedParticipant *> *)participants
                          data:(NSData *)data
         localizableMessageKey:(NSString *)key
                     arguments:(NSArray<NSString *> *)arguments
                       timeout:(NSTimeInterval)timeout
             completionHandler:(void(^__nullable)(GKTurnBasedExchange *exchange, NSError *error))completionHandler

At this point, I'm thinking my best option is to run my own push notification logic to trigger updating match data. That or I've read that sending reminders is more reliable though I believe there are throttling limits around that.

Update

I've tried using only devices and not the simulator. Same issue. Looks like it's a pretty well known problem though. It's even noted in this book on page 766.

Update

Sending reminders didn't help.

Update

Often when replying to an exchange, I'll get this error from GameKit.

The connection to service named com.apple.gamed was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.
Offside answered 2/1, 2016 at 20:28 Comment(6)
Something to note as well, I'm using the simulator plus a device. I'm trying two devices only for now as per this post: #7935836Offside
Have you tried today? I have been working with GC API for last couple months, and suddenly today all the issues I have with GC starting to work properly.Philippe
@user523234, no I haven't. And it actually does go through periods where it works as expected but, not for long.Offside
@Philippe I was having an issue where I wasn't receiving push notifications from endTurnWithNextParticipants and after reading your comment I just tried it today and it works.Crowned
Did you find the cause for the "The connection to service named com.apple.gamed ...". Any clue what the message means?Photography
@FredrikJohansson nope. I ended up removing GameKit entirely.Offside
M
0

Exchanges has until Oct 2020 never actually worked as needed, nor as specified, due to a bug in the Apple backend. Now however, an Apple engineer seem to suggest it has been fixed - asking me to verify that it works. Which I intend to do ASAP (I just need to update Xcode) using my public project: https://github.com/Gatada/TurnBasedGameFlow

FURTHER DETAIL

A turn based exchange relies on the turn holder being notified when the exchange is completed, so the turn holder can resolve it (submit it to Game Center). This notification however, was never pushed to the turn holder.

As a result of this bug, the games we made had to rely on the turn holder re-loading the game after the exchange completes, and our code had to gracefully handle the turn submission failing due to game data being out-of-sync (caused by the completed exchange).

I had a one-on-one Game Center session with Apple during WWDC 2020, where I reported this issue with hard evidence (after all, this bug had been around since 2010) which convinced the Apple engineer. It took them 3 months to get back to me, and another 3 months for me to get back to them - hehe, bringing us to now.

Mining answered 12/1, 2021 at 15:26 Comment(1)
Yikes. 10 years? I guess not too many devs have been relying on it. Has it been fixed?Bivalve

© 2022 - 2024 — McMap. All rights reserved.