-->

How do I reply to a GKTurnBasedExchange? GKLocalPl

2019-02-19 08:01发布

问题:

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.