123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // MLAdManager.m
- // XenonSDK
- //
- // Created by fq on 2021/4/21.
- // Copyright © 2021 SAGESSE. All rights reserved.
- //
- #import "MLAdManager.h"
- #import "FqAdsplashAdView.h"
- #import "FqBUDFullScreenVideo.h"
- #import "FqBUDExpressInterstitial.h"
- #import "FqBUDExpressRewardedVideo.h"
- #import "FqBUDNativeExpressBanner.h"
- #import "FqBUDExpressNativeAd.h"
- #import "FqBUDNewInterstitialAd.h"
- #import <AppTrackingTransparency/AppTrackingTransparency.h>
- @interface MLAdManager()
- @property(nonatomic,strong)FqAdsplashAdView *splashview;
- @property(nonatomic,strong)FqBUDFullScreenVideo *fullscreenVideo;
- @property(nonatomic,strong)FqBUDExpressInterstitial *interstitialAd;
- @property(nonatomic,strong)FqBUDNewInterstitialAd *interstitialNewAd;
- @property(nonatomic,strong)FqBUDExpressRewardedVideo *rewardedVideo;
- @property(nonatomic,strong)FqBUDNativeExpressBanner *nativeBanner;
- @property(nonatomic,strong)FqBUDExpressNativeAd *nativeAd;
- @end
- @implementation MLAdManager
- #pragma mark - 单利 懒加载
- + (instancetype)sharedInstance{
- return [[super alloc]init];
- }
- + (instancetype)allocWithZone:(struct _NSZone *)zone {
- static MLAdManager *instance;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- instance = [super allocWithZone:zone];
-
- NSInteger territory = [[NSUserDefaults standardUserDefaults]integerForKey:@"territory"];
- BOOL isNoCN = (territory>0&&territory!=BUAdSDKTerritory_CN);
- ///optional
- ///CN china, NO_CN is not china
- ///you must set Territory first, if you need to set them
- [BUAdSDKManager setTerritory:isNoCN?BUAdSDKTerritory_NO_CN:BUAdSDKTerritory_CN];
- //[BUAdSDKManager setGDPR:0];
- [BUAdSDKManager setCoppa:0];
- #if DEBUG
- [BUAdSDKManager setLoglevel:BUAdSDKLogLevelDebug];
- #endif
- //BUAdSDK requires iOS 9 and up
- NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
- NSString *csjAppId = [infos objectForKey:@"csjAppId"];
- if (csjAppId.length == 0) {
- NSLog(@"【穿山甲广告】,error=应用ID为空!!");
- csjAppId = @"";
- }else{
- //iOS14.5 数据跟踪,需要征求用户同意弹窗.
- if (@available(iOS 14, *)) {
- [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
- [BUAdSDKManager setAppID:csjAppId];
- }];
- }else{
- [BUAdSDKManager setAppID:csjAppId];
-
- }
- [BUAdSDKManager setIsPaidApp:NO];
-
-
- instance.splashview = [[FqAdsplashAdView alloc]init]; //1.开屏广告
- instance.fullscreenVideo = [[FqBUDFullScreenVideo alloc]init]; //2.全屏广告
- instance.interstitialAd = [[FqBUDExpressInterstitial alloc]init]; //3.插页广告
- instance.interstitialNewAd = [[FqBUDNewInterstitialAd alloc]init]; //新插屏广告
- instance.rewardedVideo = [[FqBUDExpressRewardedVideo alloc]init]; //4.视频激励广告
- instance.nativeBanner = [[FqBUDNativeExpressBanner alloc]init]; //5.原生(模板)横幅广告
- instance.nativeAd = [[FqBUDExpressNativeAd alloc]init]; //6.原生(模板)广告
- }
-
-
-
- });
- return instance;
- }
- //1. 打开开屏广告
- -(void)openSplashAd:(NSString *)adName callback:(void (^)(BOOL))callback {
- [self.splashview opensplashAd:adName callback:callback];
- }
- //2.打开全屏广告
- -(void)openFullScreenVideoAd:(NSString *)adName callback:(void (^)(BOOL))callback {
- [self.fullscreenVideo openFullScreenVideoAd:adName callback:callback];
- }
- //3.2打开新插屏广告
- -(void)openNewInterstitialAd:(NSString *)adName callback:(void (^)(BOOL))callback {
-
- [self.interstitialNewAd openNewInterstitialAd:adName callback:callback];
-
- }
- //3.打开插屏广告
- -(void)openExpressInterstitialAd:(NSString *)adName Width:(CGFloat)w Height:(CGFloat)h callback:(void (^)(BOOL))callback{
- [self.interstitialAd openInterstitialAd:adName Width:w Height:h callback:callback];
- }
- //4. 打开视频激励广告
- -(void)openExpressRewardedVideoAd:(NSString *)adName callback:(void (^)(BOOL,BOOL))callback{
- [self.rewardedVideo openRewardedVideoAd:adName callback:callback];
- }
- //5.打开横幅广告
- -(void)openNativeExpressBannerAd:(NSString *)adName WithX:(CGFloat)x Y:(CGFloat)y Width:(CGFloat)w Height:(CGFloat)h callback:(void (^)(BOOL))callback {
-
- [self.nativeBanner openNativeExpressBannerAd:adName WithX:x Y:y Width:w Height:h callback:callback];
-
- }
- //5.2 关闭横幅广告
- -(void)closeBannerAd:(NSString *)adName {
-
- [self.nativeBanner closeBanner:adName];
-
- }
- //6. 打开原生广告
- -(void)openNativeAd:(NSString *)adName WidthCGRect:(CGRect)rect BUSize:(NSInteger)size callback:(void (^)(BOOL))callback {
-
- [self.nativeAd openNativeAd:adName WidthCGRect:rect BUSize:size callback:callback];
-
- }
- @end
|