I been trying to integrate Game Center in my game for the past 2 days, but I keep getting "This game is not recognized by Game Center" in the Simulator as well as in the device.
I created a new Cocos2d project (using the Cocos2d template) and added this Game Center helper class (from raywenderlich.com tutorial). Here is the code for the class that I added to my clean Cocos2d project:
//
// GCHelper.h
//
//
//
//
//
#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>
@interface GCHelper : NSObject
{
BOOL gameCenterAvailable;
BOOL userAuthenticated;
}
@property (assign, readonly) BOOL gameCenterAvailable;
+ (GCHelper *)sharedInstance;
- (void)authenticateLocalUser;
@end
//
// GCHelper.m
//
//
//
//
//
#import "GCHelper.h"
@implementation GCHelper
@synthesize gameCenterAvailable;
#pragma mark Initialization
static GCHelper *sharedHelper = nil;
+ (GCHelper *) sharedInstance
{
if (!sharedHelper)
{
sharedHelper = [[GCHelper alloc] init];
}
return sharedHelper;
}
- (BOOL)isGameCenterAvailable
{
// check for presence of GKLocalPlayer API
Class gcClass = (NSClassFromString(@"GKLocalPlayer"));
// check if the device is running iOS 4.1 or later
NSString *reqSysVer = @"4.1";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer
options:NSNumericSearch] != NSOrderedAscending);
return (gcClass && osVersionSupported);
}
- (id)init
{
if ((self = [super init]))
{
gameCenterAvailable = [self isGameCenterAvailable];
if (gameCenterAvailable)
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(authenticationChanged)
name:GKPlayerAuthenticationDidChangeNotificationName
object:nil];
}
}
return self;
}
- (void)authenticationChanged
{
if ([GKLocalPlayer localPlayer].isAuthenticated && !userAuthenticated)
{
NSLog(@"Authentication changed: player authenticated.");
userAuthenticated = TRUE;
}
else if (![GKLocalPlayer localPlayer].isAuthenticated && userAuthenticated)
{
NSLog(@"Authentication changed: player not authenticated");
userAuthenticated = FALSE;
}
}
#pragma mark User functions
- (void)authenticateLocalUser
{
if (!gameCenterAvailable) return;
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil];
}
else
{
NSLog(@"Already authenticated!");
}
}
@end
And added this to the AppDelegate.m
#import "GCHelper.h"
// At the end of applicationDidFinishLaunching, right before
// the last line that calls runWithScene:
[[GCHelper sharedInstance] authenticateLocalUser];
Here are some screen shots of how I made the App ID, and how I added the application to iTunes Connect:
Creating the App ID:
![]()
Creating the Provisioning Profile:
![]()
Adding the app in iTunes Connect:
![]()
App information was created:
![]()
Enabling Game Center:
![]()
Enabling Game Center in Current Version:
![]()
Setting the Bundle Identifier in XCODE:
![]()
And when I run the application this is what I get:
![]()
I have read hundreds of posts and the solutions in these posts is either:
- Do a Clean in XCODE.
- Delete app from device and reinstall it.
- Make sure you are using the correct Bundle Identifier.
I have tried all those and I still get "This game is not recognized by Game Center" in simulator and device.
I'm not using a jailbroken device either.
Any help will be gretely appreciated.