Explorar el Código

修改开屏广告

jiaxian_he hace 9 meses
padre
commit
33a1203a02

+ 1 - 1
般若/Podfile

@@ -6,7 +6,7 @@ target '般若' do
   # use_frameworks!
 
     pod 'AFNetworking', '4.0.1'
-    pod 'JXHKit', :git => 'https://github.com/JiaxianHe2016/JXHKit.git'
+    pod 'JXHKit', :git => 'https://github.com/JiaxianHe2023/JXHKit.git'
     
     pod 'UMCommon'
     pod 'UMDevice'

+ 1 - 1
般若/般若.xcodeproj/project.pbxproj

@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 51;
+	objectVersion = 54;
 	objects = {
 
 /* Begin PBXBuildFile section */

+ 1 - 1
般若/般若/BanRuo/AppDelegate+XSBRConfiguration.m

@@ -88,7 +88,7 @@
 //    [BUAdSDKManager setIsPaidApp:false];
 #if DEBUG
     //Whether to open log. default is none.
-    [BUAdSDKManager setLoglevel:BUAdSDKLogLevelDebug];
+//    [BUAdSDKManager setLoglevel:BUAdSDKLogLevelDebug];
 #endif
 }
 

+ 76 - 45
般若/般若/Public/Manager/XSBROpenADManager.m

@@ -15,7 +15,7 @@
 
 @interface XSBROpenADManager ()<BUSplashAdDelegate> {
     UIButton *_adSkipButton;
-    BUSplashAdView *_splashView;
+    BUSplashAd *_splashAd;
     UIView *_adBottomView;
 }
 
@@ -35,30 +35,39 @@
 }
 
 - (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.backgroundColor = xsbr_FFFFFF_color(1.f);
@@ -71,54 +80,76 @@
         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(@"-=-=-=-=-=--点击了广告");
     [self closeAD];
     
 }
 
-- (void)splashAdDidClose:(BUSplashAdView *)splashAd {
+- (void)splashAdDidClose:(BUSplashAd *)splashAd closeType:(BUSplashAdCloseType)closeType {
     debugLog(@"-=-=-=-=-=--关闭广告");
 }
 
-- (void)splashAdDidCloseOtherController:(BUSplashAdView *)splashAd interactionType:(BUInteractionType)interactionType {
+- (void)splashDidCloseOtherController:(BUSplashAd *)splashAd interactionType:(BUInteractionType)interactionType {
     debugLog(@"-=-=-=-=-=--关闭广告详情");
     [jxh_appDelegate() showHomePage];
 }
 
-- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError *)error {
+- (void)splashAdLoadFail:(BUSplashAd *)splashAd error:(BUAdError *_Nullable)error {
     debugLog(@"-=-=-=-=-=--获取广告失败");
     [self closeAD];
     [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
 
 static XSBROpenADManager *_openADManager = nil;
-XSBROpenADManager *xsbr_openADManager() {
+XSBROpenADManager *xsbr_openADManager(void) {
     if (!_openADManager) {
         static dispatch_once_t once;
         dispatch_once(&once, ^{