Question

I call Chartboost interstitial at applicationDidBecomeActive. My game use s Game Center and sometimes GC authorization window pops up under Chartboost interstitial, blocking Chartboost window. Only solution is switch to GameCenter and login there. Is it possible to check what authorization window was shown?

Was it helpful?

Solution

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

OTHER TIPS

This is and old question but I just had the same problem and found a workaround.

Change the modalPresentationStyle of the gamecenter loggin view (returned by the ios 6 authentication handler) to UIModalPresentationFullScreen.

On iphone the screen doesn't lock when gamecenter loggin and chartboost interstitial appear. Only on Ipad happens. And whats the difference? that in ipad the loggin is not fullscreen. So I tested changing it to fullscreen and now it works without locking =)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top