Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8097135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:39:49+00:00 2026-06-05T21:39:49+00:00

I’m trying to implement invitations with Game Center and there’s one thing that i

  • 0

I’m trying to implement invitations with Game Center and there’s one thing that i don’t understand. Ok, i’ve sent an invitation from one device to another. Then i have an UIAlertView on receiver which asks me i would like to accept or decline the invitation. when i accept it it is handled like this:

[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) 
                 {
                     // Insert application-specific code here to clean up any games in progress.
                     if (acceptedInvite)
                     {
                         GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
                         mmvc.matchmakerDelegate = self;
                         [presentingViewController presentModalViewController:mmvc animated:YES];
                     }
                     else if (playersToInvite)
                     {
                         GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
                         request.minPlayers = 2;
                         request.maxPlayers = 4;
                         request.playersToInvite = playersToInvite;

                         GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
                         mmvc.matchmakerDelegate = self;
                         [presentingViewController presentModalViewController:mmvc animated:YES];

                     }
                 };

Well, that’s great, but what next? the sender device is obviously waiting for some standard type of response, cause it also shows an alert telling me that there’s some invitations not answered yet if i tap “Play now”.

So how do i accept an invitation? What kind of data (and how) should i send back? And what exactly should i do on the receiver’s side? Should game start instantly after tapping “Accept” or i should dismiss the AlertView first and then tap “Play now”?

Ray Wenderlich’s tutorial says that i should choose second way but when dismiss the alert and tap “Play now” it turns out the sender device is still waiting for response and is not aware that i have already accepted the invitation. if i tap “Play now” at this moment then, as i said above, it shows an alert which says that the application is waiting for the response. So if you’ve ever done that then please explain me what should i do. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:39:51+00:00Added an answer on June 5, 2026 at 9:39 pm
    1. I register for invites as soon as the game is loaded and call the
      delegate when an invite is received
    2. So inviteReceived calls the match maker for dismissing the game
      center controller and creating the match
    3. And finally, when the match is being found, the method
      connectionStatusChanged takes care of presenting all the game’s
      views and players and stuff

    Here is the code:

    I register for invites as soon as the game is loaded and call the delegate when an invite is received:

    - (void)registerInvites {
        [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {
            self.pendingInvite = acceptedInvite;
            self.pendingPlayersToInvite = playersToInvite;
            [delegate inviteReceived];
        };
    }
    

    So inviteReceived calls the match maker for dismissing the game center controller and creating the match:

    - (void)inviteReceived {
        [[GCMultiplayerHelper sharedInstance] findMatchWithMinPlayers:2 maxPlayers:2 viewController:(UIViewController*)[self.superview nextResponder] delegate:self];
    }
    
    
    - (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController delegate:(id<GCMultiplayerHelperDelegate>)theDelegate {
        if (!gameCenterAvailable) return;
    
        matchStarted = NO;
        self.match = nil;
        self.presentingViewController = viewController;
        delegate = theDelegate;
    
        [presentingViewController dismissModalViewControllerAnimated:YES];
        GKMatchmakerViewController *mmvc;
    
        if (pendingInvite != nil) {
    
            mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:pendingInvite] autorelease];
    
        } else {
    
            GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; 
            request.minPlayers = minPlayers;     
            request.maxPlayers = maxPlayers;
            request.playersToInvite = pendingPlayersToInvite;
    
            mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];    
    
        }
    
        mmvc.matchmakerDelegate = self;
        [presentingViewController presentModalViewController:mmvc animated:YES];
    
        self.pendingInvite = nil;
        self.pendingPlayersToInvite = nil;
    }
    

    And finally, when the match is been found, the method connectionStatusChanged takes care of presenting all the game’s views, players and starting the match:

    - (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)theMatch
    {
        self.match = theMatch;
        match.delegate = self;
        if (!matchStarted && match.expectedPlayerCount == 0) {
            NSLog(@"Ready to start match! - didFindMatch");
            [presentingViewController dismissModalViewControllerAnimated:YES];
    
            [self.delegate connectionStatusChanged:CONNECTIONSUCCESS];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I know there's a lot of other questions out there that deal with this
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.