YLHAdManager.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // YLHAdManager.m
  3. // XenonSDK
  4. //
  5. // Created by fq on 2021/4/28.
  6. // Copyright © 2021 SAGESSE. All rights reserved.
  7. //
  8. #import "YLHAdManager.h"
  9. #import "GDTSDKConfig.h"
  10. #import "FqGDTSplashAd.h"
  11. #import "FqGDTExpressInterstitialAd.h"
  12. #import "FqGTDFullScreenVideoAd.h"
  13. #import "FqGDTRewardedVideoAd.h"
  14. #import "FqGDTBannerAd.h"
  15. #import "FqGDTExpressNativeAd.h"
  16. @interface YLHAdManager()
  17. //开屏广告
  18. @property(nonatomic,strong)FqGDTSplashAd *splashAd;
  19. //模板2 插屏半屏广告
  20. @property(nonatomic,strong)FqGDTExpressInterstitialAd *interstitialAd;
  21. //模板2 插屏全屏广告
  22. @property(nonatomic,strong)FqGTDFullScreenVideoAd *fullScreenAd;
  23. //视频激励广告
  24. @property(nonatomic,strong)FqGDTRewardedVideoAd *rewardVideoAd;
  25. //横幅广告
  26. @property(nonatomic,strong)FqGDTBannerAd *bannerAd;
  27. //原生广告
  28. @property(nonatomic,strong)FqGDTExpressNativeAd *nativeAd;
  29. @end
  30. @implementation YLHAdManager
  31. #pragma mark - 单利 懒加载
  32. + (instancetype)sharedInstance{
  33. return [[super alloc]init];
  34. }
  35. + (instancetype)allocWithZone:(struct _NSZone *)zone {
  36. static YLHAdManager *instance;
  37. static dispatch_once_t onceToken;
  38. dispatch_once(&onceToken, ^{
  39. instance = [super allocWithZone:zone];
  40. #if DEBUG
  41. //...
  42. #endif
  43. NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
  44. NSString *csjAppId = [infos objectForKey:@"ylhAppId"];
  45. if (csjAppId.length == 0) {
  46. NSLog(@"【优量汇广告】,error=应用ID为空!!");
  47. csjAppId = @"";
  48. }else{
  49. BOOL result = [GDTSDKConfig registerAppId:csjAppId];
  50. if (result) {
  51. NSLog(@"优量汇SDK初始化成功.");
  52. //[GDTSDKConfig setChannel:3]; //设置渠道号
  53. NSLog(@"version=%@",[GDTSDKConfig sdkVersion]);
  54. instance.splashAd = [[FqGDTSplashAd alloc]init]; //开屏广告
  55. instance.interstitialAd = [[FqGDTExpressInterstitialAd alloc]init]; //插屏半屏广告
  56. instance.fullScreenAd = [[FqGTDFullScreenVideoAd alloc]init]; //插屏全屏广告
  57. instance.rewardVideoAd = [[FqGDTRewardedVideoAd alloc]init]; //视频激励广告
  58. instance.bannerAd = [[FqGDTBannerAd alloc]init]; //横幅广告
  59. instance.nativeAd = [[FqGDTExpressNativeAd alloc]init]; //原生广告
  60. }
  61. }
  62. });
  63. return instance;
  64. }
  65. -(void)openSplashAd:(NSString *)adName supportZoomoutView:(BOOL)flag callback:(void (^)(BOOL))callback {
  66. [self.splashAd opensplashAd:adName supportZoomoutView:flag callback:callback];
  67. }
  68. -(void)openExpressInterstitialAd:(NSString *)adName callback:(void (^)(BOOL))callback {
  69. [self.interstitialAd openInterstitialAd:adName callback:callback];
  70. }
  71. -(void)openFullScreenVideoAd:(NSString *)adName callback:(void (^)(BOOL))callback {
  72. [self.fullScreenAd openFullScreenVideoAd:adName callback:callback];
  73. }
  74. -(void)openExpressRewardedVideoAd:(NSString *)adName callback:(void (^)(BOOL, BOOL))callback {
  75. [self.rewardVideoAd openExpressRewardedVideoAd:adName callback:callback];
  76. }
  77. -(void)openExpressBannerVideoAd:(NSString *)adName callback:(void (^)(BOOL))callback {
  78. [self.bannerAd openExpressBannerAd:adName callback:callback];
  79. }
  80. -(void)openExpressNativeAdWithPlacementId:(NSString *)placementId AdName:(NSString *)adName Frame:(CGRect)rect callback:(void (^)(BOOL))callback {
  81. [self.nativeAd openExpressNativeAdWithPlacementId:placementId AdName:adName Frame:rect callback:callback];
  82. }
  83. -(void)closeExpressNativeAd:(NSString *)adName {
  84. //预留接口
  85. }
  86. @end