// // TOPONAdManager.m // XenonSDK // // Created by fq on 2021/5/11. // Copyright © 2021 SAGESSE. All rights reserved. // #import "TOPONAdManager.h" #import #import #import "XSNetwork.h" #import "FqToPONSplashAd.h" #import "FqToPONInterstitialAd.h" #import "FqToPONRewardedVideoAd.h" #import "FqToPONBannerAd.h" #import "FqToPONExpressNativeAd.h" @interface TOPONAdManager() //开屏广告 @property(nonatomic,strong)FqToPONSplashAd *splashAd; //插屏广告 @property(nonatomic,strong)FqToPONInterstitialAd *interstitialAd; //视频激励广告 @property(nonatomic,strong)FqToPONRewardedVideoAd *rewardVideoAd; //横幅广告 @property(nonatomic,strong)FqToPONBannerAd *bannerAd; //原生广告 @property(nonatomic,strong)FqToPONExpressNativeAd *nativeAd; @end @implementation TOPONAdManager + (instancetype)sharedInstance{ return [[super alloc]init]; } + (instancetype)allocWithZone:(struct _NSZone *)zone { static TOPONAdManager *instance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance = [super allocWithZone:zone]; #if DEBUG //... #endif NSDictionary *infos = [[NSBundle mainBundle] infoDictionary]; NSString *topOnAppId = [infos objectForKey:@"topOnAppId"]; NSString *appKey = [infos objectForKey:@"topOnAppKey"]; if (topOnAppId.length == 0) { NSLog(@"【TopOn广告】,error=应用ID为空!!"); [XSNetwork showHudFailure:@"TopOn:应用ID为空"]; topOnAppId = @""; }else if (appKey.length == 0){ NSLog(@"【TopOn广告】,error=appKey为空!!"); [XSNetwork showHudFailure:@"TopOn:appKey为空"]; }else{ [ATAPI setLogEnabled:YES]; //iOS14.5 数据跟踪,需要征求用户同意弹窗. if (@available(iOS 14, *)) { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { [[ATAPI sharedInstance] startWithAppID:topOnAppId appKey:appKey error:nil]; }]; }else{ [[ATAPI sharedInstance] startWithAppID:topOnAppId appKey:appKey error:nil]; } #if DEBUG [ATAPI integrationChecking]; #endif instance.splashAd = [[FqToPONSplashAd alloc]init]; //开屏广告 instance.interstitialAd = [[FqToPONInterstitialAd alloc]init]; //插屏广告 instance.rewardVideoAd = [[FqToPONRewardedVideoAd alloc]init]; //视频激励广告 instance.bannerAd = [[FqToPONBannerAd alloc]init]; //横幅广告 instance.nativeAd = [[FqToPONExpressNativeAd alloc]init]; //原生广告 } }); return instance; } -(void)opensplashAd:(NSString *)adName callback:(void (^)(BOOL))callback { [self.splashAd opensplashAd:adName callback:callback]; } -(void)openInterstitialAd:(NSString *)adName callback:(void (^)(BOOL))callback { [self.interstitialAd openInterstitialAd:adName callback:callback]; } -(void)openRewardedVideoAd:(NSString *)adName callback:(void (^)(BOOL,BOOL))callback { [self.rewardVideoAd openRewardedVideoAd:adName callback:callback]; } -(void)openExpressBannerAd:(NSString *)adName callback:(void (^)(BOOL))callback { [self.bannerAd openBannerAd:adName callback:callback]; } -(void)openNativeAdWithX:(int)x Y:(int)y width:(int)w height:(int)h adId:(NSString *)adName callback:(void (^)(BOOL))callback { [self.nativeAd openNativeAdWithX:x Y:y width:w height:h adId:adName callback:callback]; } @end