|
@@ -15,7 +15,7 @@
|
|
|
|
|
|
@interface XSBROpenADManager ()<BUSplashAdDelegate> {
|
|
@interface XSBROpenADManager ()<BUSplashAdDelegate> {
|
|
UIButton *_adSkipButton;
|
|
UIButton *_adSkipButton;
|
|
- BUSplashAdView *_splashView;
|
|
|
|
|
|
+ BUSplashAd *_splashAd;
|
|
UIView *_adBottomView;
|
|
UIView *_adBottomView;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -35,30 +35,39 @@
|
|
}
|
|
}
|
|
|
|
|
|
- (void)setOpenAD {
|
|
- (void)setOpenAD {
|
|
- _splashView = [[BUSplashAdView alloc] initWithSlotID:@"887292818" frame:CGRectMake(0, 0, jxh_screenWidth(), jxh_screenHeight() - XSBRStarPageBottomViewHeight - jxh_safeInsets(xsbr_keyWindow()).bottom)];
|
|
|
|
- _splashView.backgroundColor = xsbr_FFFFFF_color(1.f);
|
|
|
|
- _splashView.hideSkipButton = true;
|
|
|
|
- _splashView.delegate = self;
|
|
|
|
- _splashView.tolerateTimeout = 3;
|
|
|
|
- [_splashView loadAdData];
|
|
|
|
|
|
+ _splashAd = [[BUSplashAd alloc] initWithSlotID:@"887292818" adSize:CGSizeMake(jxh_screenWidth(), jxh_screenHeight() - XSBRStarPageBottomViewHeight - jxh_safeInsets(xsbr_keyWindow()).bottom)];
|
|
|
|
+ _splashAd.splashView.backgroundColor = xsbr_FFFFFF_color(1.f);
|
|
|
|
+ _splashAd.hideSkipButton = true;
|
|
|
|
+ _splashAd.delegate = self;
|
|
|
|
+ _splashAd.tolerateTimeout = 3;
|
|
|
|
+ [_splashAd loadAdData];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)splashAdDidLoad:(BUSplashAdView *)splashAd {
|
|
|
|
- [jxh_appDelegate() changeTabBarType:XSBRTabBarTypeHome];
|
|
|
|
- [xsbr_keyWindow().rootViewController.view addSubview:_splashView];
|
|
|
|
- _splashView.rootViewController = xsbr_keyWindow().rootViewController;
|
|
|
|
|
|
+- (void)closeAD {
|
|
|
|
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
|
|
+ if (_splashAd) {
|
|
|
|
+ [_splashAd removeSplashView];
|
|
|
|
+ [_adBottomView removeFromSuperview];
|
|
|
|
+ [_adSkipButton removeFromSuperview];
|
|
|
|
+// _adSkipButton = nil;
|
|
|
|
+// _adBottomView = nil;
|
|
|
|
+// _splashAd = nil;
|
|
|
|
+ }
|
|
|
|
|
|
- _adSkipButton = [UIButton convenienceWithFont:xsbr_font(14) target:self action:@selector(skipAd)];
|
|
|
|
- [_adSkipButton setTitle:@"跳过" titleColor:xsbr_FFFFFF_color(1.f) state:JXHButtonControlStateNormal];
|
|
|
|
- _adSkipButton.backgroundColor = xsbr_000000_color(0.5);
|
|
|
|
- [_adSkipButton setLayerCornerRadius:15 clipToBounds:false];
|
|
|
|
- [xsbr_keyWindow().rootViewController.view addSubview:_adSkipButton];
|
|
|
|
- [_adSkipButton makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
|
- make.trailing.equalTo(-16);
|
|
|
|
- make.top.equalTo(50);
|
|
|
|
- make.size.equalTo(CGSizeMake(50, 30));
|
|
|
|
-
|
|
|
|
- }];
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)skipAd {
|
|
|
|
+ [self closeAD];
|
|
|
|
+ [jxh_appDelegate() showHomePage];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma mark - BUSplashAdDelegate
|
|
|
|
+
|
|
|
|
+- (void)splashAdLoadSuccess:(BUSplashAd *)splashAd {
|
|
|
|
+ [jxh_appDelegate() changeTabBarType:XSBRTabBarTypeHome];
|
|
|
|
+ [_splashAd showSplashViewInRootViewController:xsbr_keyWindow().rootViewController];
|
|
|
|
+// [xsbr_keyWindow().rootViewController.view addSubview:_splashAd];
|
|
|
|
+// _splashAd.rootViewController = xsbr_keyWindow().rootViewController;
|
|
|
|
|
|
_adBottomView = [[UIView alloc] initWithFrame:CGRectMake(0, jxh_screenHeight() - XSBRStarPageBottomViewHeight - jxh_safeInsets(xsbr_keyWindow()).bottom, jxh_screenWidth(), XSBRStarPageBottomViewHeight + jxh_safeInsets(xsbr_keyWindow()).bottom)];
|
|
_adBottomView = [[UIView alloc] initWithFrame:CGRectMake(0, jxh_screenHeight() - XSBRStarPageBottomViewHeight - jxh_safeInsets(xsbr_keyWindow()).bottom, jxh_screenWidth(), XSBRStarPageBottomViewHeight + jxh_safeInsets(xsbr_keyWindow()).bottom)];
|
|
_adBottomView.backgroundColor = xsbr_FFFFFF_color(1.f);
|
|
_adBottomView.backgroundColor = xsbr_FFFFFF_color(1.f);
|
|
@@ -71,54 +80,76 @@
|
|
make.centerY.equalTo(self->_adBottomView).offset(-jxh_safeInsets(xsbr_keyWindow()).bottom / 2);
|
|
make.centerY.equalTo(self->_adBottomView).offset(-jxh_safeInsets(xsbr_keyWindow()).bottom / 2);
|
|
}];
|
|
}];
|
|
|
|
|
|
- [self performSelector:@selector(skipAd) withObject:nil afterDelay:3];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)closeAD {
|
|
|
|
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
|
|
- if (_splashView) {
|
|
|
|
- [_splashView removeFromSuperview];
|
|
|
|
- [_adBottomView removeFromSuperview];
|
|
|
|
- [_adSkipButton removeFromSuperview];
|
|
|
|
-// _adSkipButton = nil;
|
|
|
|
-// _adBottomView = nil;
|
|
|
|
-// _splashView = nil;
|
|
|
|
- }
|
|
|
|
|
|
+- (void)splashAdRenderSuccess:(nonnull BUSplashAd *)splashAd {
|
|
|
|
+ _adSkipButton = [UIButton convenienceWithFont:xsbr_font(14) target:self action:@selector(skipAd)];
|
|
|
|
+ [_adSkipButton setTitle:@"跳过" titleColor:xsbr_FFFFFF_color(1.f) state:JXHButtonControlStateNormal];
|
|
|
|
+ _adSkipButton.backgroundColor = xsbr_000000_color(0.5);
|
|
|
|
+ [_adSkipButton setLayerCornerRadius:15 clipToBounds:false];
|
|
|
|
+ [_splashAd.splashView addSubview:_adSkipButton];
|
|
|
|
+ [_adSkipButton makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
|
+ make.trailing.equalTo(-16);
|
|
|
|
+ make.top.equalTo(50);
|
|
|
|
+ make.size.equalTo(CGSizeMake(50, 30));
|
|
|
|
+
|
|
|
|
+ }];
|
|
|
|
|
|
|
|
+ [self performSelector:@selector(skipAd) withObject:nil afterDelay:3];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)skipAd {
|
|
|
|
- [self closeAD];
|
|
|
|
- [jxh_appDelegate() showHomePage];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-#pragma mark - BUSplashAdDelegate
|
|
|
|
-
|
|
|
|
-- (void)splashAdDidClick:(BUSplashAdView *)splashAd {
|
|
|
|
|
|
+- (void)splashAdDidClick:(BUSplashAd *)splashAd {
|
|
debugLog(@"-=-=-=-=-=--点击了广告");
|
|
debugLog(@"-=-=-=-=-=--点击了广告");
|
|
[self closeAD];
|
|
[self closeAD];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)splashAdDidClose:(BUSplashAdView *)splashAd {
|
|
|
|
|
|
+- (void)splashAdDidClose:(BUSplashAd *)splashAd closeType:(BUSplashAdCloseType)closeType {
|
|
debugLog(@"-=-=-=-=-=--关闭广告");
|
|
debugLog(@"-=-=-=-=-=--关闭广告");
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)splashAdDidCloseOtherController:(BUSplashAdView *)splashAd interactionType:(BUInteractionType)interactionType {
|
|
|
|
|
|
+- (void)splashDidCloseOtherController:(BUSplashAd *)splashAd interactionType:(BUInteractionType)interactionType {
|
|
debugLog(@"-=-=-=-=-=--关闭广告详情");
|
|
debugLog(@"-=-=-=-=-=--关闭广告详情");
|
|
[jxh_appDelegate() showHomePage];
|
|
[jxh_appDelegate() showHomePage];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError *)error {
|
|
|
|
|
|
+- (void)splashAdLoadFail:(BUSplashAd *)splashAd error:(BUAdError *_Nullable)error {
|
|
debugLog(@"-=-=-=-=-=--获取广告失败");
|
|
debugLog(@"-=-=-=-=-=--获取广告失败");
|
|
[self closeAD];
|
|
[self closeAD];
|
|
[jxh_appDelegate() showHomePage];
|
|
[jxh_appDelegate() showHomePage];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)splashAdRenderFail:(BUSplashAd *)splashAd error:(BUAdError *_Nullable)error {
|
|
|
|
+ debugLog(@"-=-=-=-=-=--广告渲染失败");
|
|
|
|
+ [self closeAD];
|
|
|
|
+ [jxh_appDelegate() showHomePage];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)splashVideoAdDidPlayFinish:(BUSplashAd *)splashAd didFailWithError:(NSError *)error {
|
|
|
|
+ debugLog(@"-=-=-=-=-=--广告播放失败");
|
|
|
|
+ [self closeAD];
|
|
|
|
+ [jxh_appDelegate() showHomePage];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)splashAdDidShow:(nonnull BUSplashAd *)splashAd {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+- (void)splashAdViewControllerDidClose:(nonnull BUSplashAd *)splashAd {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+- (void)splashAdWillShow:(nonnull BUSplashAd *)splashAd {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
static XSBROpenADManager *_openADManager = nil;
|
|
static XSBROpenADManager *_openADManager = nil;
|
|
-XSBROpenADManager *xsbr_openADManager() {
|
|
|
|
|
|
+XSBROpenADManager *xsbr_openADManager(void) {
|
|
if (!_openADManager) {
|
|
if (!_openADManager) {
|
|
static dispatch_once_t once;
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
dispatch_once(&once, ^{
|