Blocking ads when Game Center login is on screen might be an option! Code works only on iOS6 btw
@interface ChartboostBridge : NSObject<ChartboostDelegate>
@end
@implementation ChartboostBridge
- (BOOL)shouldDisplayInterstitial:(NSString *)location{
NSLog(@"CB shouldDisplayInterstitial for %@",location);
if ([location isEqualToString:@"game_launch"]) {
if( [[GameCenterIos shared ] hasLogInView] ){
return NO;
}
}
return YES;
}
@end
@implementation GameCenterIos
- (BOOL)hasLogInView{
return isViewOnScreen;
}
- (void)login
{
GKLocalPlayer* localPlayer = [GKLocalPlayer localPlayer];
if (localPlayer.isAuthenticated) {
isViewOnScreen=NO;
return;
}
localPlayer.authenticateHandler =
^(UIViewController *viewController,
NSError *error) {
if (localPlayer.authenticated) {
isAuthenticated = YES;
isViewOnScreen=NO;
} else if(viewController) {
NSLog(@"Game Center shows login ....");
isViewOnScreen=YES;
[self presentViewController:viewController];
} else {
NSLog(@"Game Center error or canceled login ....");
//User canceled Login view
isAuthenticated = NO;
isViewOnScreen=NO;
}
};
}
#pragma mark UIViewController stuff
-(UIViewController*) getRootViewController {
return [UIApplication
sharedApplication].keyWindow.rootViewController;
}
-(void)presentViewController:(UIViewController*)vc {
UIViewController* rootVC = [self getRootViewController];
[rootVC presentViewController:vc animated:YES
completion:nil];
}
@end