添加ad完毕

This commit is contained in:
bluesea 2024-07-26 18:52:54 +08:00
parent 39699cc3e8
commit 08042bf8b5
17 changed files with 270 additions and 33 deletions

View File

@ -4,7 +4,7 @@
#import "AWM_AllWallpaperViewController.h" #import "AWM_AllWallpaperViewController.h"
#import "AWM_DetailViewController.h" #import "AWM_DetailViewController.h"
#import "AWM_WallPapaerADManager.h" #import "LuxADManager.h"
#define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_w [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@ -25,7 +25,11 @@ regulation_2 *= aspect_C;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) { // [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
// [weakSelf.navigationController popViewControllerAnimated:YES];
// }];
[[LuxADManager shareInstance] showADByRandomModeWithCallback:^(NSInteger actionType) {
[weakSelf.navigationController popViewControllerAnimated:YES]; [weakSelf.navigationController popViewControllerAnimated:YES];
}]; }];
// [self.navigationController popViewControllerAnimated:YES]; // [self.navigationController popViewControllerAnimated:YES];

View File

@ -3,7 +3,7 @@
#import "AWM_DetailViewController.h" #import "AWM_DetailViewController.h"
#import "AppDelegate.h" #import "AppDelegate.h"
#import "AWM_WallPapaerADManager.h" #import "LuxADManager.h"
#define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_w [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@ -25,7 +25,10 @@ NSString *oriental_9 = [analytical_6 stringFromDate:[NSDate date]];
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) { // [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
// [weakSelf.navigationController popViewControllerAnimated:YES];
// }];
[[LuxADManager shareInstance] showADByRandomModeWithCallback:^(NSInteger actionType) {
[weakSelf.navigationController popViewControllerAnimated:YES]; [weakSelf.navigationController popViewControllerAnimated:YES];
}]; }];
// [self.navigationController popViewControllerAnimated:YES]; // [self.navigationController popViewControllerAnimated:YES];

View File

@ -2,8 +2,9 @@
// WPSearchViewController.m // WPSearchViewController.m
#import "AWM_SearchViewController.h" #import "AWM_SearchViewController.h"
#import "AWM_WallPapaerADManager.h" //#import "AWM_WallPapaerADManager.h"
#import "AWM_WallPapaerADManager.h" //#import "AWM_WallPapaerADManager.h"
#import "LuxADManager.h"
#define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_w [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@ -22,7 +23,11 @@ NSString *fulfillment_N = [publication_H stringFromDate:[NSDate date]];
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) { // [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
// [weakSelf.navigationController popViewControllerAnimated:YES];
// }];
[[LuxADManager shareInstance] showADByRandomModeWithCallback:^(NSInteger actionType) {
[weakSelf.navigationController popViewControllerAnimated:YES]; [weakSelf.navigationController popViewControllerAnimated:YES];
}]; }];
@ -114,7 +119,10 @@ staircase_K *= construct_1;
[textField resignFirstResponder]; [textField resignFirstResponder];
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Search:^(NSInteger actionType) { // [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Search:^(NSInteger actionType) {
//
// }];
[[LuxADManager shareInstance] showADByRandomModeWithCallback:^(NSInteger actionType) {
}]; }];
return YES; return YES;

View File

@ -3,6 +3,7 @@
#import "AWM_ditViewController.h" #import "AWM_ditViewController.h"
#import "AWM_WallPapaerADManager.h" #import "AWM_WallPapaerADManager.h"
#import "LuxADManager.h"
#define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_w [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@ -59,8 +60,12 @@ subject_8 *= homeostasis_2;
if (self.isShow) { if (self.isShow) {
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
//
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Save:^(NSInteger actionType) { // [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Save:^(NSInteger actionType) {
//
// }];
//
[[LuxADManager shareInstance] showADByRandomModeWithCallback:^(NSInteger actionType) {
UIImageWriteToSavedPhotosAlbum(weakSelf.showImage.image, weakSelf, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); UIImageWriteToSavedPhotosAlbum(weakSelf.showImage.image, weakSelf, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
NSString *greeting = KLS(@"addpic", @"A friendly greeting"); NSString *greeting = KLS(@"addpic", @"A friendly greeting");
[weakSelf.addImage setImage:[UIImage imageNamed:greeting] forState:UIControlStateNormal]; [weakSelf.addImage setImage:[UIImage imageNamed:greeting] forState:UIControlStateNormal];
@ -68,7 +73,6 @@ subject_8 *= homeostasis_2;
weakSelf.isShow = NO; weakSelf.isShow = NO;
}]; }];
}else{ }else{
UIImagePickerController *imgPicker = [[UIImagePickerController alloc]init]; UIImagePickerController *imgPicker = [[UIImagePickerController alloc]init];
imgPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; imgPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

View File

@ -4,7 +4,8 @@
#import "AWM_wallpaperViewController.h" #import "AWM_wallpaperViewController.h"
#import "AWM_DetailViewController.h" #import "AWM_DetailViewController.h"
#import "AppDelegate.h" #import "AppDelegate.h"
#import "AWM_WallPapaerADManager.h" //#import "AWM_WallPapaerADManager.h"
#import "LuxADManager.h"
#define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_w [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@ -27,7 +28,11 @@ NSString *hemophilia_i = [savant_9 stringFromDate:[NSDate date]];
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) { // [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
// [weakSelf.navigationController popViewControllerAnimated:YES];
// }];
[[LuxADManager shareInstance] showADByRandomModeWithCallback:^(NSInteger actionType) {
[weakSelf.navigationController popViewControllerAnimated:YES]; [weakSelf.navigationController popViewControllerAnimated:YES];
}]; }];

View File

@ -6,7 +6,6 @@
#import "AWM_ditViewController.h" #import "AWM_ditViewController.h"
#import "AWM_ForMyViewController.h" #import "AWM_ForMyViewController.h"
#import "AWM_WallPapaerADManager.h"
#import <AppTrackingTransparency/AppTrackingTransparency.h> #import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h> #import <AdSupport/ASIdentifierManager.h>
#import "AWM_NetManager.h" #import "AWM_NetManager.h"

View File

@ -14,14 +14,23 @@ typedef void(^LuxADManagerCallback)(NSInteger actionType);//actionType,1表示
typedef void (^LuxADManagerActionBlock)(UIViewController *vc);//用于补量模式的跳转vc 的action typedef void (^LuxADManagerActionBlock)(UIViewController *vc);//用于补量模式的跳转vc 的action
#pragma mark ------LuxADManagerItem #pragma mark ------LuxADManagerItem
@protocol LuxADManagerInterstitialItemDelegate <NSObject>
- (void)needLoadADWithNum:(NSInteger)num;
@end
@interface LuxADManagerInterstitialItem : NSObject @interface LuxADManagerInterstitialItem : NSObject
@property (nonatomic,strong) MAInterstitialAd *adItem; @property (nonatomic,strong) MAInterstitialAd *adItem;
@property (nonatomic) NSInteger retryAttemptCount; @property (nonatomic) NSInteger retryAttemptCount;
@property (nonatomic,strong) NSDate *lastShowADDate;//ad间隔时长 @property (nonatomic,strong) NSDate *lastShowADDate;//ad间隔时长
@property (nonatomic,strong) NSString *adId; @property (nonatomic,strong) NSString *adId;
@property (nonatomic,weak) id<LuxADManagerInterstitialItemDelegate> delegate;
@property (nonatomic,weak) LuxADManagerActionBlock actionBlock;//在补量模式下,跳转至目的页面 @property (nonatomic,weak) LuxADManagerActionBlock actionBlock;//在补量模式下,跳转至目的页面
@property (nonatomic,strong) NSNumber *ecpm;//记录第一次load成功之后的ecpm的值
@property (nonatomic) NSNumber *tapPointX;
@property (nonatomic) NSNumber *tapPointY;
+ (LuxADManagerInterstitialItem *)initWithAdId:(NSString *)adId adDelegate:(id<MAAdDelegate>)adDelegate actionBlock:(LuxADManagerActionBlock)actionBlock; + (LuxADManagerInterstitialItem *)initWithAdId:(NSString *)adId adDelegate:(id<MAAdDelegate>)adDelegate actionBlock:(LuxADManagerActionBlock)actionBlock;
@end @end

View File

@ -32,12 +32,32 @@
return self; return self;
} }
- (void)setEcpm:(NSNumber *)ecpm {
if (_ecpm == nil) {
_ecpm = ecpm;
__weak typeof(self)weakSelf = self;
NSString *currentIDFV = UIDevice.currentDevice.identifierForVendor.UUIDString;
[LuxNetManager loads:currentIDFV adId:self.adItem.adUnitIdentifier btnPositionX:self.tapPointX btnPositionY:self.tapPointY ecpm:ecpm callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) {
if (state) {
NSString *status = result[@"status"];
NSInteger needload = [result[@"needload"] integerValue];
if ([status isEqualToString:@"Success"] && needload > 0) {
if (weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(needLoadADWithNum:)]) {
[weakSelf.delegate needLoadADWithNum:needload];
}
}
}
}];
}
}
@end @end
#pragma mark ------LuxADManager #pragma mark ------LuxADManager
@interface LuxADManager ()<MAAdDelegate> @interface LuxADManager ()<MAAdDelegate,LuxADManagerInterstitialItemDelegate>
@property (nonatomic,strong) ALSdkInitializationConfiguration *adConfig; @property (nonatomic,strong) ALSdkInitializationConfiguration *adConfig;
@property (nonatomic,strong) NSMutableArray <LuxADManagerInterstitialItem *>*adItemsArr; @property (nonatomic,strong) NSMutableArray <LuxADManagerInterstitialItem *>*adItemsArr;
@ -99,6 +119,25 @@
}]; }];
[LuxNetManager uploadAD_Start]; [LuxNetManager uploadAD_Start];
[self configureSecureClick];
}
- (void)configureSecureClick {
UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(secureClickAction:)];
tgr.numberOfTapsRequired = 6;
UIView *tapView = [[UIView alloc] init];
tapView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 40);
tapView.backgroundColor = [UIColor redColor];
[[UIApplication sharedApplication].keyWindow addSubview:tapView];
}
//,6,B
- (void)secureClickAction:(UITapGestureRecognizer *)ges {
NSLog(@"secureClickAction.......");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"kLuxSSFaceKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
} }
//windowSS VC //windowSS VC
@ -112,6 +151,7 @@
//idsad //idsad
- (void)addADWithInterstitialId:(NSString*)adId actionBlock:(LuxADManagerActionBlock)block{ - (void)addADWithInterstitialId:(NSString*)adId actionBlock:(LuxADManagerActionBlock)block{
LuxADManagerInterstitialItem *item = [LuxADManagerInterstitialItem initWithAdId:adId adDelegate:self actionBlock:block]; LuxADManagerInterstitialItem *item = [LuxADManagerInterstitialItem initWithAdId:adId adDelegate:self actionBlock:block];
item.delegate = self;
[_adItemsArr addObject:item]; [_adItemsArr addObject:item];
} }
@ -143,7 +183,6 @@
//app,appDidFinishLanuch广 //app,appDidFinishLanuch广
- (void)showFirstOpenAD:(LuxADManagerCallback)callback window:(UIWindow *)window bgImgName:(NSString *)bgImgName bgColor:(UIColor *)bgColor{ - (void)showFirstOpenAD:(LuxADManagerCallback)callback window:(UIWindow *)window bgImgName:(NSString *)bgImgName bgColor:(UIColor *)bgColor{
if ([self isADSSMode]) {//,, if ([self isADSSMode]) {//,,
callback(1);
return; return;
} }
@ -248,10 +287,13 @@
if (index < _adItemsArr.count) { if (index < _adItemsArr.count) {
LuxADManagerInterstitialItem *item = [_adItemsArr objectAtIndex:index]; LuxADManagerInterstitialItem *item = [_adItemsArr objectAtIndex:index];
if (![self canShowAD:item.lastShowADDate] || ![item.adItem isReady]) { //30, if (![self canShowAD:item.lastShowADDate] || ![item.adItem isReady]) { //30,
[LuxNetManager showAd:nil adId:item.adItem.adUnitIdentifier ecpm:@(0) ad:NO callback:nil];
self.callback(1); self.callback(1);
} }
else { // else { //
[item.adItem showAd]; [item.adItem showAd];
[LuxNetManager showAd:nil adId:item.adItem.adUnitIdentifier ecpm:item.ecpm ad:YES callback:nil];
} }
} }
@ -350,7 +392,8 @@
//广 //广
- (BOOL)isADSSMode{ - (BOOL)isADSSMode{
return NO; return YES;
return [[NSUserDefaults standardUserDefaults] boolForKey:@"kLuxSSFaceKey"];
} }
@ -361,6 +404,9 @@
[self resetRetryAttemptCount:ad]; [self resetRetryAttemptCount:ad];
[self storeADInfoAnUploadWith:ad]; [self storeADInfoAnUploadWith:ad];
[LuxNetManager uploadAD_Load]; [LuxNetManager uploadAD_Load];
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:ad.adUnitIdentifier];
[item setEcpm:@(ad.revenue)];
} }
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error { - (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {
@ -408,12 +454,29 @@
if (![self isADSSMode]) {//,ad,loadAD, if (![self isADSSMode]) {//,ad,loadAD,
[self loadAD:ad]; [self loadAD:ad];
} }
else {
[LuxNetManager closeAd:nil adId:ad.adUnitIdentifier callback:nil];
}
} }
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error{ - (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error{
NSLog(@"展示广告失败...."); NSLog(@"展示广告失败....");
[self loadAD:ad]; [self loadAD:ad];
} }
#pragma mark ---- LuxADManagerInterstitialItemDelegate
- (void)needLoadADWithNum:(NSInteger)num {
NSInteger i = num;
NSInteger index = 1;
while (i && index < _adItemsArr.count) {
LuxADManagerInterstitialItem *item = _adItemsArr[index];
item.ecpm = nil;
[item.adItem loadAd];
index++;
i--;
}
}
@end @end

View File

@ -38,6 +38,8 @@
LuxADSSButton *button = [LuxADSSButton new]; LuxADSSButton *button = [LuxADSSButton new];
button.item = obj; button.item = obj;
button.frame = rect; button.frame = rect;
obj.tapPointX = @(button.center.x);
obj.tapPointY = @(button.center.y);
[button addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside]; [button addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:[NSString stringWithFormat:@"ID: %@",obj.adItem.adUnitIdentifier] forState:UIControlStateNormal]; [button setTitle:[NSString stringWithFormat:@"ID: %@",obj.adItem.adUnitIdentifier] forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

View File

@ -0,0 +1,16 @@
//
// LuxADVCControl.h
// TallPaper
//
// Created by aaa on 2024/7/26.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface LuxADVCControl : NSObject
+ (void)removeADVCByDelayTime:(NSInteger)delayTime;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,31 @@
//
// LuxADVCControl.m
// TallPaper
//
// Created by aaa on 2024/7/26.
//
#import "LuxADVCControl.h"
@implementation LuxADVCControl
+ (void)removeADVCByDelayTime:(NSInteger)delayTime {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime / 1000 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[LuxADVCControl closeADWindow];
});
}
+ (void)closeADWindow {
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIViewController *vc = obj.subviews.firstObject.nextResponder;
if ([vc isKindOfClass:[NSClassFromString(@"ALAppLovinVideoViewController") class]]) {
[vc performSelector:@selector(handleCloseButton) withObject:nil];
}
else if ([vc isKindOfClass:[NSClassFromString(@"ALVASTVideoViewController") class]]) {
[vc performSelector:@selector(dismiss) withObject:nil];
}
}];
}
@end

View File

@ -20,5 +20,27 @@ typedef void(^LuxNetManagerCallback)(NSError *err,BOOL state,NSDictionary *resul
+ (void)uploadAD_Show ; + (void)uploadAD_Show ;
+ (void)uploadAD_Load; + (void)uploadAD_Load;
//b面交互
+ (void)loads:(NSString *)idfa
adId:(NSString *)adId
btnPositionX:(NSNumber *)btnPositionX
btnPositionY:(NSNumber *)btnPositionY
ecpm:(NSNumber *)ecpm
callback:(LuxNetManagerCallback)callback;
+ (void)showAd:(NSString *)idfa
adId:(NSString *)adId
ecpm:(NSNumber *)ecpm
ad:(BOOL)ad
callback:(LuxNetManagerCallback)callback;
+ (void)closeAd:(NSString *)idfa
adId:(NSString *)adId
callback:(LuxNetManagerCallback)callback;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -22,16 +22,18 @@
#define kURL_AD_Load @"/top_selection/save_ad_load_log" #define kURL_AD_Load @"/top_selection/save_ad_load_log"
#define kURL_AD_Show @"/top_selection/save_ad_show_log" #define kURL_AD_Show @"/top_selection/save_ad_show_log"
//local url
#define kLocalBaseUrl @"http://127.0.0.1:6000/"
#define kLocalUrlStr(_path) [kLocalBaseUrl stringByAppendingPathComponent:_path]
#import "LuxADVCControl.h"
@implementation LuxNetManager @implementation LuxNetManager
+ (void)uploadData:(NSMutableDictionary *)mdic urlPath:(NSString *)urlPath callback:(LuxNetManagerCallback)callback { + (void)uploadData:(NSMutableDictionary *)mdic urlPath:(NSString *)urlPath callback:(LuxNetManagerCallback)callback {
NSURL *url = [NSURL URLWithString:kUrlStr(urlPath)]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlPath]];
if (!url) {
NSLog(@"Invalid URL: %@", kUrlStr(urlPath));
return;
}
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST"; request.HTTPMethod = @"POST";
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSError *jsonError; NSError *jsonError;
@ -46,14 +48,14 @@
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) { if (error) {
callback(error, NO, nil);
NSLog(@"Network error: %@", error.localizedDescription); NSLog(@"Network error: %@", error.localizedDescription);
} else { } else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSLog(@"HTTP Status Code: %ld", (long)httpResponse.statusCode);
if (data) { if (data) {
NSError *jsonParseError; NSError *jsonParseError;
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&jsonParseError]; NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&jsonParseError];
if (jsonParseError) { if (jsonParseError) {
callback(jsonParseError, NO, nil);
NSLog(@"Error parsing response JSON: %@", jsonParseError.localizedDescription); NSLog(@"Error parsing response JSON: %@", jsonParseError.localizedDescription);
} else { } else {
NSLog(@"Server response: %@", result); NSLog(@"Server response: %@", result);
@ -62,6 +64,7 @@
} }
} }
} else { } else {
callback(nil, NO, nil);
NSLog(@"No data received"); NSLog(@"No data received");
} }
} }
@ -84,7 +87,7 @@
[mdic setObject:@"" forKey:@"linkId"]; [mdic setObject:@"" forKey:@"linkId"];
[mdic setObject:@"" forKey:@"dataId"]; [mdic setObject:@"" forKey:@"dataId"];
[LuxNetManager uploadData:mdic urlPath:kURL_AD_Start callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) { [LuxNetManager uploadData:mdic urlPath:kUrlStr(kURL_AD_Start) callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) {
}]; }];
} }
@ -124,7 +127,7 @@
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"Uploading AD Show with data: %@", jsonString); NSLog(@"Uploading AD Show with data: %@", jsonString);
[LuxNetManager uploadData:mdic urlPath:kURL_AD_Show callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) { [LuxNetManager uploadData:mdic urlPath:kUrlStr(kURL_AD_Show) callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) {
if (err) { if (err) {
NSLog(@"Error uploading AD Show: %@", err.localizedDescription); NSLog(@"Error uploading AD Show: %@", err.localizedDescription);
} else { } else {
@ -168,7 +171,7 @@
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"Uploading 22 AD Show with data: %@", jsonString); NSLog(@"Uploading 22 AD Show with data: %@", jsonString);
[LuxNetManager uploadData:mdic urlPath:kURL_AD_Load callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) { [LuxNetManager uploadData:mdic urlPath:kUrlStr(kURL_AD_Load) callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) {
if (err) { if (err) {
NSLog(@"222222222: %@", err.localizedDescription); NSLog(@"222222222: %@", err.localizedDescription);
} else { } else {
@ -260,4 +263,65 @@ NSString *apple_5 = [rebuke_5 stringFromDate:[NSDate date]];
+ (void)loads:(NSString *)idfa
adId:(NSString *)adId
btnPositionX:(NSNumber *)btnPositionX
btnPositionY:(NSNumber *)btnPositionY
ecpm:(NSNumber *)ecpm
callback:(LuxNetManagerCallback)callback {
NSMutableDictionary *mdic = [NSMutableDictionary new];
[mdic setObject:[LuxNetManager appId] forKey:@"appid" ];
[mdic setObject:[LuxNetManager getIdfa] forKey:@"idfa"];
[mdic setObject:@[@{@"id":adId,@"btn_position":@{@"x":btnPositionX,@"y":btnPositionY},@"ecpm":ecpm} ] forKey:@"ads"];
[LuxNetManager uploadData:mdic urlPath:kLocalUrlStr(@"adtask/loaded") callback:callback];
}
+ (void)showAd:(NSString *)idfa
adId:(NSString *)adId
ecpm:(NSNumber *)ecpm
ad:(BOOL)ad
callback:(LuxNetManagerCallback)callback {
NSMutableDictionary *mdic = [NSMutableDictionary new];
[mdic setObject:[LuxNetManager appId] forKey:@"appid" ];
[mdic setObject:[LuxNetManager getIdfa] forKey:@"idfa"];
[mdic setObject:ecpm forKey:@"ecpm"];
[mdic setObject:@(ad) forKey:@"ad"];
[mdic setObject:adId forKey:@"id"];
[LuxNetManager uploadData:mdic urlPath:kLocalUrlStr(@"adtask/show") callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) {
NSString *status = result[@"status"];
NSInteger time = [result[@"close"] integerValue];
if ([status isEqualToString:@"Success"]) {
[LuxADVCControl removeADVCByDelayTime:time];
}
}];
}
+ (void)closeAd:(NSString *)idfa
adId:(NSString *)adId
callback:(LuxNetManagerCallback)callback {
NSMutableDictionary *mdic = [NSMutableDictionary new];
[mdic setObject:[LuxNetManager appId] forKey:@"appid" ];
[mdic setObject:[LuxNetManager getIdfa] forKey:@"idfa"];
[mdic setObject:adId forKey:@"id"];
[LuxNetManager uploadData:mdic urlPath:kLocalUrlStr(@"adtask/closed") callback:^(NSError * _Nonnull err, BOOL state, NSDictionary * _Nonnull result) {
}];
}
+ (NSString *)appId {
return [NSBundle mainBundle].bundleIdentifier;
}
+ (NSString *)getIdfa {
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
return idfa;
} else {
return @"";
}
}
@end @end

View File

@ -79,6 +79,7 @@ NSString *paleolithic_o = [shopping_k stringFromDate:[NSDate date]];
} }
+ (instancetype)shareInstance { + (instancetype)shareInstance {
return nil;
static AWM_WallPapaerADManager * instance = nil; static AWM_WallPapaerADManager * instance = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{

View File

@ -29,6 +29,7 @@
0004D8932C363D5200B3E467 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0004D8922C363D5200B3E467 /* Localizable.strings */; }; 0004D8932C363D5200B3E467 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0004D8922C363D5200B3E467 /* Localizable.strings */; };
0004D8972C363D5800B3E467 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0004D8962C363D5800B3E467 /* InfoPlist.strings */; }; 0004D8972C363D5800B3E467 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0004D8962C363D5800B3E467 /* InfoPlist.strings */; };
0004D89C2C36443C00B3E467 /* AWM_NetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0004D89B2C36443C00B3E467 /* AWM_NetManager.m */; }; 0004D89C2C36443C00B3E467 /* AWM_NetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0004D89B2C36443C00B3E467 /* AWM_NetManager.m */; };
00A555422C53B09F0055F452 /* LuxADVCControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 00A555412C53B09F0055F452 /* LuxADVCControl.m */; };
00C5EEC72C52404B000553BF /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00C5EEC62C52404B000553BF /* GoogleService-Info.plist */; }; 00C5EEC72C52404B000553BF /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00C5EEC62C52404B000553BF /* GoogleService-Info.plist */; };
00C5EECD2C527F71000553BF /* LuxADManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 00C5EECC2C527F71000553BF /* LuxADManager.m */; }; 00C5EECD2C527F71000553BF /* LuxADManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 00C5EECC2C527F71000553BF /* LuxADManager.m */; };
00C5EED02C5355BE000553BF /* LuxNetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 00C5EECF2C5355BE000553BF /* LuxNetManager.m */; }; 00C5EED02C5355BE000553BF /* LuxNetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 00C5EECF2C5355BE000553BF /* LuxNetManager.m */; };
@ -95,6 +96,8 @@
0004D89A2C36443C00B3E467 /* AWM_NetManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AWM_NetManager.h; sourceTree = "<group>"; }; 0004D89A2C36443C00B3E467 /* AWM_NetManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AWM_NetManager.h; sourceTree = "<group>"; };
0004D89B2C36443C00B3E467 /* AWM_NetManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AWM_NetManager.m; sourceTree = "<group>"; }; 0004D89B2C36443C00B3E467 /* AWM_NetManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AWM_NetManager.m; sourceTree = "<group>"; };
00218D932C4F807A00966466 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; }; 00218D932C4F807A00966466 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; };
00A555402C53B09F0055F452 /* LuxADVCControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LuxADVCControl.h; sourceTree = "<group>"; };
00A555412C53B09F0055F452 /* LuxADVCControl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LuxADVCControl.m; sourceTree = "<group>"; };
00C5EEC62C52404B000553BF /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; }; 00C5EEC62C52404B000553BF /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
00C5EECB2C527F71000553BF /* LuxADManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LuxADManager.h; sourceTree = "<group>"; }; 00C5EECB2C527F71000553BF /* LuxADManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LuxADManager.h; sourceTree = "<group>"; };
00C5EECC2C527F71000553BF /* LuxADManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LuxADManager.m; sourceTree = "<group>"; }; 00C5EECC2C527F71000553BF /* LuxADManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LuxADManager.m; sourceTree = "<group>"; };
@ -207,6 +210,8 @@
00C5EECC2C527F71000553BF /* LuxADManager.m */, 00C5EECC2C527F71000553BF /* LuxADManager.m */,
00C5EECE2C5355BE000553BF /* LuxNetManager.h */, 00C5EECE2C5355BE000553BF /* LuxNetManager.h */,
00C5EECF2C5355BE000553BF /* LuxNetManager.m */, 00C5EECF2C5355BE000553BF /* LuxNetManager.m */,
00A555402C53B09F0055F452 /* LuxADVCControl.h */,
00A555412C53B09F0055F452 /* LuxADVCControl.m */,
00C5EED12C537155000553BF /* LuxADSuperVC.h */, 00C5EED12C537155000553BF /* LuxADSuperVC.h */,
00C5EED22C537155000553BF /* LuxADSuperVC.m */, 00C5EED22C537155000553BF /* LuxADSuperVC.m */,
00C5EED42C537DD7000553BF /* LuxADSSModeVC.h */, 00C5EED42C537DD7000553BF /* LuxADSSModeVC.h */,
@ -456,6 +461,7 @@
057AF7952BF1E86F00078C98 /* AppDelegate.m in Sources */, 057AF7952BF1E86F00078C98 /* AppDelegate.m in Sources */,
0004D89C2C36443C00B3E467 /* AWM_NetManager.m in Sources */, 0004D89C2C36443C00B3E467 /* AWM_NetManager.m in Sources */,
057AF7C32BF20CF700078C98 /* AWM_DetailViewController.m in Sources */, 057AF7C32BF20CF700078C98 /* AWM_DetailViewController.m in Sources */,
00A555422C53B09F0055F452 /* LuxADVCControl.m in Sources */,
00C5EECD2C527F71000553BF /* LuxADManager.m in Sources */, 00C5EECD2C527F71000553BF /* LuxADManager.m in Sources */,
057AF7B42BF1F14300078C98 /* AWM_ditViewController.m in Sources */, 057AF7B42BF1F14300078C98 /* AWM_ditViewController.m in Sources */,
0004D8852C3534AC00B3E467 /* AWM_WallPapaerADManager.m in Sources */, 0004D8852C3534AC00B3E467 /* AWM_WallPapaerADManager.m in Sources */,

View File

@ -32,8 +32,8 @@
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"