vendredi 24 juin 2016

Game Center Stuck in invitation

I am developing cocos2dx game for iOS, i have integrated the Game Center but when i send invitation to friend the sender did not recive the response that receiver accepted the request or not none of delegate method is calling. I have tried all the solutions but nothing is working further i can share the code if there is anything wrong with it:

GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.inviteMessage = @"Your Custom Invitation Message Here";

request.inviteeResponseHandler = ^(NSString *playerID, GKInviteeResponse response)
{
    if (response == GKInviteeResponseAccepted)
    {
        NSLog(@"DEBUG: Player Accepted: %@", playerID);
        // Tell the infrastructure we are don matching and will start using the match
    }
};

[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch* match, NSError *error) {
    if (error)
    {
        //Invite has not been sent

          NSLog(@"Invitation has not been sent");
    }
    else if (match != nil)
    {
        //whatever you want to do when the receiver accepts the invite
        NSLog(@"Invitation has  been sent with match object = %@",match);

    }
}];
request.recipientResponseHandler= ^(GKPlayer *player, GKInviteeResponse response)
{


    switch (response) {
        case GKInviteeResponseAccepted:
        {
        }
            break;
        case GKInviteeResponseDeclined:
        {

        }
            break;
        case GKInviteeResponseFailed:
        {

        }
            break;
        case GKInviteeResponseIncompatible:
        {

        }
            break;
        case GKInviteeResponseUnableToConnect:
        {


        }
            break;
        case GKInviteeResponseNoAnswer:
        {


        }
            break;

        default:
            break;
    }

};

GKMatchmakerViewController *mmvc =
    [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;

[viewController presentViewController:mmvc animated:YES completion:nil];

Aucun commentaire:

Enregistrer un commentaire