Matchmaking works on wifi but doesn't work on 3g

97 views Asked by At

For some reason game center matchMaking works well when both devices on the same wifi but does not work when one of the devices is on 3g (the devices keep searching and cannot find each other). I am using: 1. iPad 2 with iOS 7.0.4 with sandbox account (compatible to the device's app store account) 2. Iphone 4s with iOS 7.0.4 with sandbox account (compatible to the device's app store account but different from the iPad account).

The code that create the match goes like this:

- (IBAction)continueButtonPressed:(id)sender {
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.defaultNumberOfPlayers = 2;
if(([[self.gameTypeSegmentControl objectAtIndex:0] selectedSegmentIndex] == 0) ||
   ([[self.gameTypeSegmentControl objectAtIndex:1] selectedSegmentIndex] == 0))
{
    int temp = [self.allLanguages indexOfObject:[[self.languages objectAtIndex:selectedRow] primaryLanguage]];
    if ((temp > 0) && (temp <= self.allLanguages.count))
    {
        request.playerGroup = temp;
    }else
    {
        request.playerGroup = ENGLISH_US_LANG;//50
    }
}
if(([[self.gameTypeSegmentControl objectAtIndex:0] selectedSegmentIndex] == 1) ||
   ([[self.gameTypeSegmentControl objectAtIndex:1] selectedSegmentIndex] == 1))
{
    request.playerGroup = 255;
}

if (isJoining)// Not the creator of the game
{
    request.playerAttributes = JOIN_ATTRIBUTE;
    [[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
        if (error)
        {
            NSLog(@"findMatchForRequest ended with error");
            // Process the error.
        }
        else if (match != nil)
        {
            self.myMatch = match; // Use a retaining property to retain the match.
            match.delegate = self;
            if (!self.matchStarted && match.expectedPlayerCount == 0)
            {
                self.matchStarted = YES;
                NSLog(@"match begin");
                // Insert game-specific code to begin the match.
            }
        }
    }];
}else //The creator of the game
{
    request.playerAttributes = CREATE_ATTRIBUTE;
    GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
    mmvc.matchmakerDelegate = self;

    [self presentViewController:mmvc animated:YES completion:nil];
}    

}

Any idea what causing the problem???

0

There are 0 answers