我在applicationDidBecomeActive
致电Chartboost插页式广告。我的游戏使用了游戏中心,有时在Chartboost
插页式广告,Chartboost
窗口阻止下会弹出GC授权窗口。只有解决方案切换到GameCenter
并在那里登录。是否可以检查显示的授权窗口是什么?
答案 0 :(得分:2)
在屏幕上注册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
答案 1 :(得分:0)
这是老问题,但我遇到了同样的问题并找到了解决方法。
将游戏中心登录视图的modalPresentationStyle(由ios 6身份验证处理程序返回)更改为 UIModalPresentationFullScreen 。
在iphone上,当出现gamecenter loggin和chartboost插页式广告时,屏幕不会锁定。只有在Ipad上才会发生。什么是差异?在ipad中,登录不是全屏。所以我测试了将它更改为全屏,现在它无需锁定即可工作=)