123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //
- // YLHAdManager.m
- // XenonSDK
- //
- // Created by fq on 2021/4/28.
- // Copyright © 2021 SAGESSE. All rights reserved.
- //
- #import "YLHAdManager.h"
- #import "GDTSDKConfig.h"
- #import "FqGDTSplashAd.h"
- #import "FqGDTExpressInterstitialAd.h"
- #import "FqGTDFullScreenVideoAd.h"
- #import "FqGDTRewardedVideoAd.h"
- #import "FqGDTBannerAd.h"
- #import "FqGDTExpressNativeAd.h"
- @interface YLHAdManager()
- //开屏广告
- @property(nonatomic,strong)FqGDTSplashAd *splashAd;
- //模板2 插屏半屏广告
- @property(nonatomic,strong)FqGDTExpressInterstitialAd *interstitialAd;
- //模板2 插屏全屏广告
- @property(nonatomic,strong)FqGTDFullScreenVideoAd *fullScreenAd;
- //视频激励广告
- @property(nonatomic,strong)FqGDTRewardedVideoAd *rewardVideoAd;
- //横幅广告
- @property(nonatomic,strong)FqGDTBannerAd *bannerAd;
- //原生广告
- @property(nonatomic,strong)FqGDTExpressNativeAd *nativeAd;
- @end
- @implementation YLHAdManager
- #pragma mark - 单利 懒加载
- + (instancetype)sharedInstance{
- return [[super alloc]init];
- }
- + (instancetype)allocWithZone:(struct _NSZone *)zone {
- static YLHAdManager *instance;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- instance = [super allocWithZone:zone];
- #if DEBUG
- //...
- #endif
- NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
- NSString *csjAppId = [infos objectForKey:@"ylhAppId"];
- if (csjAppId.length == 0) {
- NSLog(@"【优量汇广告】,error=应用ID为空!!");
- csjAppId = @"";
- }else{
- BOOL result = [GDTSDKConfig registerAppId:csjAppId];
- if (result) {
- NSLog(@"优量汇SDK初始化成功.");
- //[GDTSDKConfig setChannel:3]; //设置渠道号
- NSLog(@"version=%@",[GDTSDKConfig sdkVersion]);
-
- instance.splashAd = [[FqGDTSplashAd alloc]init]; //开屏广告
- instance.interstitialAd = [[FqGDTExpressInterstitialAd alloc]init]; //插屏半屏广告
- instance.fullScreenAd = [[FqGTDFullScreenVideoAd alloc]init]; //插屏全屏广告
- instance.rewardVideoAd = [[FqGDTRewardedVideoAd alloc]init]; //视频激励广告
- instance.bannerAd = [[FqGDTBannerAd alloc]init]; //横幅广告
- instance.nativeAd = [[FqGDTExpressNativeAd alloc]init]; //原生广告
- }
-
- }
- });
- return instance;
- }
- -(void)openSplashAd:(NSString *)adName supportZoomoutView:(BOOL)flag callback:(void (^)(BOOL))callback {
-
- [self.splashAd opensplashAd:adName supportZoomoutView:flag callback:callback];
-
- }
- -(void)openExpressInterstitialAd:(NSString *)adName callback:(void (^)(BOOL))callback {
-
- [self.interstitialAd openInterstitialAd:adName callback:callback];
-
- }
- -(void)openFullScreenVideoAd:(NSString *)adName callback:(void (^)(BOOL))callback {
-
- [self.fullScreenAd openFullScreenVideoAd:adName callback:callback];
- }
- -(void)openExpressRewardedVideoAd:(NSString *)adName callback:(void (^)(BOOL, BOOL))callback {
-
- [self.rewardVideoAd openExpressRewardedVideoAd:adName callback:callback];
- }
- -(void)openExpressBannerVideoAd:(NSString *)adName callback:(void (^)(BOOL))callback {
-
- [self.bannerAd openExpressBannerAd:adName callback:callback];
- }
- -(void)openExpressNativeAdWithPlacementId:(NSString *)placementId AdName:(NSString *)adName Frame:(CGRect)rect callback:(void (^)(BOOL))callback {
-
- [self.nativeAd openExpressNativeAdWithPlacementId:placementId AdName:adName Frame:rect callback:callback];
- }
- -(void)closeExpressNativeAd:(NSString *)adName {
- //预留接口
- }
- @end
|