2016-01-22 145 views
1

我正在開發cocos2dx遊戲iOS卡住了,我已經集成了Game Center但是當我發出邀請好友發送者並沒有recive該接收機接受委託方法的要求或不沒有被調用的響應。我已經嘗試了所有的解決方案,但沒有什麼工作進一步如果有什麼不對的地方,我可以共享代碼:遊戲中心邀請

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]; 
+0

你是否收到任何GKInviteeResponse? – Striker

回答

0

這是不是一個真正的解決方案,但它是一個解決辦法。在我的情況下,我最多有4名玩家,最少爲2人。如果我向一名玩家發出邀請,並且剩下兩個插槽可供蘋果公司隨機填充,則它永遠不會進行。我發現推動事物的唯一方法是在發送邀請之前通過在空插槽上點擊X來移除空位。