How do you "decide" GKTurnBasedExchange?

I use GKTurnBasedExchange to send data one way. This notice is for other players as some triggers occur. However, other players may not even be in the game at that time. Turns have a 48-hour timeout, so theoretically, if player1 sends the exchange, player3 may not pick it up for a couple of days. In this case, player 1 does not require or expect an answer.

But, when player1 tries to save the match data, complete the move or end the match, I get an error message:

Domain Error = GKErrorDomain Code = 3 "The requested operation could not be completed due to a server related error." UserInfo = 0x19317970 {GKServerStatusCode = 5134, NSUnderlyingError = 0x16f15db0 "Operation could not be completed. Status = 5134, Invalid operation for this session because the exchange was not allowed. All exchanges must be allowed before the player can perform this operation .

OK, the bold text seems pretty straightforward, with the exception of one small detail: I cannot find any link anywhere in what constitutes an “allowed” exchange. I do not expect a response to this message. Even if I did, it would take days to get it. The only option I see is for the sender to cancel the exchange, which is detrimental to the purpose of sending the exchange in the first place

So how exactly does the exchange end? What series of steps, besides canceling the exchange, will the gaming center satisfy, that the exchange is "allowed"? I just use:

    [theMatch sendExchangeToParticipants:exchangeParticipants
                                    data:exchangeData
                   localizableMessageKey:@"F1"
                               arguments:nil
                                 timeout:600
                       completionHandler:^(GKTurnBasedExchange *exchange, NSError *error)
                       {
                           if (error)
                           {
                               VLOG(LOWLOG, @"%@", [error description]);
                           }
                       }
    ];

Followed by:

[theMatch saveCurrentTurnWithMatchData:dataCopy completionHandler:^(NSError *error)
 {
     if (error)
     {
         VLOG(LOWLOG, @"%@", [error description])
     }
 }];

A call to saveCurrentTurnWithMatchData returns the above error.

Thank!

+4
source share
3 answers

, . , , Apple.

, : .

, : , :

saveMergedMatch(matchData: Data, withResolvedExchanges: [GKTurnBasedExchange], completionHandler: ((Error?) -> Void))

.

  • currentParticipant (, ) saveMergedMatch successflly.
  • , .active.
  • , , .active.
  • : - , . , , Game Center . , , . [ , , , -, , Game Center , .]
  • : , cancel(withLocalizableMessageKey key: String, arguments: [String], completionHandler: ((Error?) -> Void)? = nil). , , , . , . , : , - .

, , , - :

  • , , , , .
  • , , currentParticipant.

, , (), , , .

+2

, , . Game Kit. , , , 506 WWDC 2013 :

  • , "".
  • :

    [match saveMergedMatchData:dataCopy
         withResolvedExchanges:match.completedExchanges
             completionHandler:...];
    

, . ( -).

+1

, , .

I think the best API for this is setLocalizableMessageWithKey (key: arguments :) or sendReminderToParticipants (localizableMessageKey: arguments: completionHandler :) in your GKTurnBasedMatch instance.

0
source

All Articles