gpt4 book ai didi

iOS GameCenter 授权窗口阻止 Chartboost

转载 作者:行者123 更新时间:2023-11-29 10:59:13 37 4
gpt4 key购买 nike

我在 applicationDidBecomeActive 调用 Chartboost interstitial。我的游戏使用 s Game Center,有时 GC 授权窗口会在 Chartboost 间隙弹出,阻止 Chartboost 窗口。唯一的解决办法是切换到 GameCenter 并在那里登录。是否可以检查显示的授权窗口?

最佳答案

当屏幕上出现 Game Center 登录时阻止广告可能是一个选项!代码仅适用于 iOS6 顺便说一句

@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 GameCenter 授权窗口阻止 Chartboost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16768136/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com