我通过applicationDidBecomeActive
将Chartboost插页式广告称为“插页式广告”。我的游戏使用的是Game Center,有时Chartboost
插页式广告下会弹出GC授权窗口,从而阻止Chartboost
窗口。唯一的解决方案是切换到GameCenter
并在那里登录。是否可以查看显示了哪个授权窗口?
最佳答案
屏幕上显示Game Center登录时阻止广告是一种选择!代码仅适用于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
关于ios - iOS GameCenter授权窗口块Chartboost,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16768136/