Commit ccf21104 authored by Mazy's avatar Mazy

optimize ad

parent f669091d
This diff is collapsed.
......@@ -248,6 +248,11 @@ NSDictionary* appLaunchOpts;
GYGiftAlertView * gift = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([GYGiftAlertView class]) owner:self options:nil].firstObject;
gift.boxModel = boxModel;
gift.frame = [[self ufw] appController].window.bounds;
for (UIView *subView in [[self ufw] appController].window.subviews) {
if (subView.tag == 1024) {
return;
}
}
[[[self ufw] appController].window addSubview:gift];
[gift show:nil];
});
......@@ -327,6 +332,7 @@ NSDictionary* appLaunchOpts;
// 获取首页信息
- (void)ios_getHomeInfo {
[self isNetworking];
[[CGNetworkTools shared] getWithAction: getHomeInfo parameters: @{} success:^(id _Nonnull response) {
if ([[response objectForKey:@"status"] integerValue] == 200) {
NSData *data = [NSJSONSerialization dataWithJSONObject:[[response objectForKey:@"result"] objectForKey:@"data"] options:NSJSONWritingFragmentsAllowed error:nil];
......@@ -638,9 +644,9 @@ NSDictionary* appLaunchOpts;
if (rewardContentList == nil){
return;
}
if (rewardContentList.count <= 0) {
return;
}
// if (rewardContentList.count <= 0) {
// return;
// }
CGFloat totalRewardNumF = [[rewardContentList.firstObject objectForKey:@"totalRewardNum"] floatValue];
NSString *totalRewardNumS = [NSString stringWithFormat:@"%.2f", totalRewardNumF / 100.0];
......@@ -655,7 +661,7 @@ NSDictionary* appLaunchOpts;
}];
} else {
[MBProgressHUD showError:@"抱歉, 请重试"];
// [MBProgressHUD showError:@"抱歉, 请重试"];
}
}];
}
......@@ -810,12 +816,14 @@ NSDictionary* appLaunchOpts;
}
- (void)applicationWillResignActive:(UIApplication *)application {
[[[self ufw] appController] applicationWillResignActive: application]; }
- (void)applicationDidEnterBackground:(UIApplication *)application {
[[[self ufw] appController] applicationDidEnterBackground: application]; }
- (void)applicationWillEnterForeground:(UIApplication *)application {
[[[self ufw] appController] applicationWillEnterForeground: application]; }
- (void)applicationDidBecomeActive:(UIApplication *)application {
[[[self ufw] appController] applicationDidBecomeActive: application]; }
- (void)applicationWillTerminate:(UIApplication *)application {
[[[self ufw] appController] applicationWillTerminate: application]; }
......@@ -878,6 +886,42 @@ NSDictionary* appLaunchOpts;
return nil;
}
#pragma mark-监听网络
- (void)isNetworking
{
// 开启网络指示器
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown:
NSLog(@"未识别的网络");
break;
case AFNetworkReachabilityStatusNotReachable:
{
NSLog(@"无网络连接");
//跳转到“About”(关于本机)页面
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"无网络连接" message:@"请检查网络环境,并确认开启网络访问权限!" preferredStyle: UIAlertControllerStyleAlert];
UIAlertAction *setting = [UIAlertAction actionWithTitle:@"检查网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
}];
[alertVC addAction:setting];
[[[self ufw] appController].window.rootViewController presentViewController:alertVC animated:true completion:nil];
}
break;
case AFNetworkReachabilityStatusReachableViaWiFi:
NSLog(@"WIFI");
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
NSLog(@"蜂窝移动");
break;
default:
break;
}
}];
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
}
@end
......@@ -48,6 +48,13 @@
</dict>
<key>NSUserTrackingUsageDescription</key>
<string>App需要打开您的广告追踪权限以追踪广告</string>
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>58922NB4GD.skadnetwork</string>
</dict>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
......@@ -75,12 +82,5 @@
</array>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>58922NB4GD.skadnetwork</string>
</dict>
</array>
</dict>
</plist>
......@@ -231,7 +231,7 @@ static IOSADManager * manager = nil;
self.haveLodeAD = YES;
loadADModel.loadADType = AdType;
if ([self.loadADDataArray count] > 10) {
if ([self.loadADDataArray count] > 6) {
[self.loadADDataArray removeObject:self.loadADDataArray.firstObject];
}
if (AdType == ADType_Video) {
......@@ -244,7 +244,7 @@ static IOSADManager * manager = nil;
if ([loadADModel.adPlatform isEqualToString:@"chuanshanjia"]) { // 穿山甲
if ([self contentADDataWith:loadADModel]) { //有数据
// 什么都不做或者 直接加载
// 什么都不做或者 直接加载
}else{
NSInteger time = 0.1;
if (self.csjAd == nil || self.loadADDataArray.count > 1) {
......@@ -252,24 +252,23 @@ static IOSADManager * manager = nil;
}else{
time = 5;
}
// 去加载
weakSelf.csjAd = nil;
AddCSJADManager * csjAd = [[AddCSJADManager alloc]init];
weakSelf.csjAd = csjAd;
[weakSelf.loadADDataArray addObject:csjAd];
csjAd.loadSuccessCallbackBlock = ^(GYAdsTrackModel * _Nonnull model, BOOL success) {
[weakSelf blockResultLoadWithData:model andSuccess:success];
};
csjAd.showSuccessCallbackBlock = ^(GYAdsTrackModel * _Nonnull model, BOOL success) {
[weakSelf blockResultShowWithData:model andSuccess:success];
};
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 去加载
weakSelf.csjAd = nil;
AddCSJADManager * csjAd = [[AddCSJADManager alloc]init];
weakSelf.csjAd = csjAd;
[weakSelf.loadADDataArray addObject:csjAd];
csjAd.loadSuccessCallbackBlock = ^(GYAdsTrackModel * _Nonnull model, BOOL success) {
[weakSelf blockResultLoadWithData:model andSuccess:success];
};
csjAd.showSuccessCallbackBlock = ^(GYAdsTrackModel * _Nonnull model, BOOL success) {
[weakSelf blockResultShowWithData:model andSuccess:success];
};
[csjAd loadAdWithData:loadADModel withADType:AdType];
});
[csjAd loadAdWithData:loadADModel withADType:AdType];
}
}else if ([loadADModel.adPlatform isEqualToString:@"guangdiantong"]){ // 广点通
if ([self contentADDataWith:loadADModel]) { //有数据
......@@ -408,28 +407,46 @@ static IOSADManager * manager = nil;
if (self.advertisingSpace) {
[[CGUserManager shared] addADLocCollection:self.advertisingSpace value:@"show_reward_video_ad" andADData:showData];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if ([showData.adPlatform isEqualToString:@"chuanshanjia"]) {
[weakSelf.csjAd showAdWithData:showData withADType:adType];
}else if ([showData.adPlatform isEqualToString:@"guangdiantong"]){
[weakSelf.gdtAd showAdWithData:showData withADType:adType];
}else if ([showData.adPlatform isEqualToString:@"sigmob"]){
[weakSelf.sigmobAd showAdWithData:showData withADType:adType];
if ([showData.adPlatform isEqualToString:@"chuanshanjia"]) {
[weakSelf.csjAd showAdWithData:showData withADType:adType];
}else if ([showData.adPlatform isEqualToString:@"guangdiantong"]){
[weakSelf.gdtAd showAdWithData:showData withADType:adType];
}else if ([showData.adPlatform isEqualToString:@"ruishi"]){
[weakSelf.ruishiAd showAdWithData:showData withADType:adType];
}
});
}else if ([showData.adPlatform isEqualToString:@"sigmob"]){
[weakSelf.sigmobAd showAdWithData:showData withADType:adType];
}else if ([showData.adPlatform isEqualToString:@"ruishi"]){
[weakSelf.ruishiAd showAdWithData:showData withADType:adType];
}
if (weakSelf.videoModels.count <= 1) {
[weakSelf requestVideoAD];
}else{
if ([showData.adPlatform isEqualToString:@"sigmob"]){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (weakSelf.videoModels.count <= 1) {
[weakSelf requestVideoAD];
}else{
[weakSelf loadAdWithData:weakSelf.videoModels[1] withADType:ADType_Video];
}
});
[weakSelf loadAdWithData:weakSelf.videoModels[1] withADType:ADType_Video];
} else {
if (weakSelf.videoModels.count <= 1) {
[weakSelf requestVideoAD];
}else{
[weakSelf loadAdWithData:weakSelf.videoModels[1] withADType:ADType_Video];
}
}
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// if (weakSelf.videoModels.count <= 1) {
// [weakSelf requestVideoAD];
// }else{
// [weakSelf loadAdWithData:weakSelf.videoModels[1] withADType:ADType_Video];
// }
// });
}else if (adType == ADType_BigImage){ //大图
}else if (adType == ADType_OpenScreen){ //开屏
......@@ -655,13 +672,9 @@ static IOSADManager * manager = nil;
[weakSelf requestVideoAD];
}
}
}else if(model.loadADType == ADType_OpenScreen){
if(success){
......@@ -707,8 +720,6 @@ static IOSADManager * manager = nil;
if(model.loadADType == ADType_Video){
// [NSObject cancelPreviousPerformRequestsWithTarget:self];
[weakSelf clearCache:model];
weakSelf.adShowBlock(success);
......@@ -722,7 +733,8 @@ static IOSADManager * manager = nil;
} failure:^(NSError * _Nonnull error) {
}];
}else{
[MBProgressHUD showMessage:@"请重试"];
// [MBProgressHUD showMessage:@"请重试"];
self.showNow = YES;
[[CGUserManager shared] addLocCollection:@"reward_request" value:@"reward_display_failed"];
if (self.advertisingSpace) {
......@@ -731,6 +743,9 @@ static IOSADManager * manager = nil;
}
}
[weakSelf clearCache:model];
}else if(model.loadADType == ADType_OpenScreen){
if (success) {
[[CGUserManager shared] addLocCollection:@"splash_back" value:@"splash_display_success"];
......@@ -739,8 +754,9 @@ static IOSADManager * manager = nil;
[[CGUserManager shared] addLocCollection:@"splash_back" value:@"splash_display_failed"];
}
[weakSelf clearCache:model];
weakSelf.adShowBlock(success);
[weakSelf clearCache:model];
weakSelf.showNow = NO;
[[NSNotificationCenter defaultCenter] postNotificationName: LaunchAdSuccesShow object:nil];
......@@ -751,11 +767,10 @@ static IOSADManager * manager = nil;
}else{
[[CGUserManager shared] addLocCollection:@"native_back" value:@"native_display_failed"];
}
[weakSelf clearCache:model];
weakSelf.adShowBlock(success);
weakSelf.showNow = NO;
[weakSelf clearCache:model];
}
......
......@@ -9,8 +9,6 @@
#import "AppDelegate.h"
@interface AddCSJADManager ()
@property (nonatomic ,retain) GYAdsTrackModel * currentData;
......@@ -25,7 +23,7 @@
- (void)loadAdWithData:(GYAdsTrackModel *)loadADModel withADType:(eADType)AdType{
self.currentData = loadADModel;
WEAKSELF;
// WEAKSELF;
GYAdsTrackModel * model = loadADModel;
if (AdType == ADType_OpenScreen) { // 开屏
CGRect frame = [UIScreen mainScreen].bounds;
......@@ -45,6 +43,11 @@
}else if (AdType == ADType_Video){ //视频
GYAdsTrackModel * oldData = [IOSADManager shareADManager].cachevideo.firstObject;
if ([oldData.adPlatform isEqualToString: @"chuanshanjia"]) {
self.loadSuccessCallbackBlock(self.currentData, NO);
return;
}
BURewardedVideoModel * rewardedModel = [[BURewardedVideoModel alloc] init];
rewardedModel.userId = USERID;
......@@ -72,15 +75,21 @@
/// @param showData 广告对象
/// @param adType 广告类型
- (void)showAdWithData:(GYAdsTrackModel *)showData withADType:(eADType)adType;{
dispatch_async(dispatch_get_main_queue(), ^{
WEAKSELF
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (adType == ADType_OpenScreen) { // 开屏
}else if (adType == ADType_Video){ //视频
if (self.rewardedAd.isAdValid) {
[self.rewardedAd showAdFromRootViewController:self.currentVC];
if (weakSelf.rewardedAd.isAdValid) {
if ([weakSelf.rewardedAd showAdFromRootViewController: [(AppDelegate *)[UIApplication sharedApplication].delegate getTopViewController]]) {
}else{
weakSelf.showSuccessCallbackBlock(showData, NO);
}
}else{
self.showSuccessCallbackBlock(showData, NO);
weakSelf.showSuccessCallbackBlock(showData, NO);
}
}else if (adType == ADType_BigImage){ //大图
......@@ -102,7 +111,8 @@
WEAKSELF;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIWindow *keyWindow = [UIApplication sharedApplication].windows.lastObject;
// UIWindow *keyWindow = [UIApplication sharedApplication].windows.lastObject;
UIWindow *keyWindow = [(AppDelegate *)[UIApplication sharedApplication].delegate getMainWindow];
[keyWindow.rootViewController.view addSubview:weakSelf.splashAd_CSJ];
weakSelf.splashAd_CSJ.rootViewController = keyWindow.rootViewController;
});
......
......@@ -6,6 +6,8 @@
//
#import "AddGDTADManager.h"
#import "AppDelegate.h"
@interface AddGDTADManager ()
@property (nonatomic ,retain) GYAdsTrackModel * currentData;
......@@ -21,7 +23,7 @@
self.currentData = loadADModel;
WEAKSELF;
// WEAKSELF;
GYAdsTrackModel * model = loadADModel;
if (AdType == ADType_OpenScreen) { // 开屏
......@@ -46,6 +48,11 @@
// });
}else if (AdType == ADType_Video){ //视频
GYAdsTrackModel * oldData = [IOSADManager shareADManager].cachevideo.firstObject;
if ([oldData.adPlatform isEqualToString: @"guangdiantong"]) {
self.loadSuccessCallbackBlock(self.currentData, NO);
return;
}
self.rewardVideoAd = [[GDTRewardVideoAd alloc] initWithPlacementId:model.codeId];
self.rewardVideoAd.videoMuted = NO;
......@@ -66,19 +73,26 @@
/// @param showData 广告对象
/// @param adType 广告类型
- (void)showAdWithData:(GYAdsTrackModel *)showData withADType:(eADType)adType;{
dispatch_async(dispatch_get_main_queue(), ^{
WEAKSELF
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (adType == ADType_OpenScreen) { // 开屏
}else if (adType == ADType_Video){ //视频
if (self.rewardVideoAd.isAdValid) {
[self.rewardVideoAd showAdFromRootViewController:self.currentVC];
// if (weakSelf.rewardVideoAd.isAdValid && [weakSelf.rewardVideoAd eCPM] > 0) {
if (weakSelf.rewardVideoAd.isAdValid) {
if ([weakSelf.rewardVideoAd showAdFromRootViewController: [(AppDelegate *)[UIApplication sharedApplication].delegate getTopViewController]]) {
}else{
weakSelf.showSuccessCallbackBlock(showData, NO);
}
}else{
self.showSuccessCallbackBlock(showData, NO);
weakSelf.showSuccessCallbackBlock(showData, NO);
}
}else if (adType == ADType_BigImage){ //大图
}
});
}
......
......@@ -18,7 +18,7 @@
- (void)loadAdWithData:(GYAdsTrackModel *)loadADModel withADType:(eADType)AdType{
self.currentData = loadADModel;
WEAKSELF;
// WEAKSELF;
GYAdsTrackModel * model = loadADModel;
if (AdType == ADType_OpenScreen) { // 开屏
......@@ -67,18 +67,20 @@
/// @param showData 广告对象
/// @param adType 广告类型
- (void)showAdWithData:(GYAdsTrackModel *)showData withADType:(eADType)adType;{
dispatch_async(dispatch_get_main_queue(), ^{
WEAKSELF
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (adType == ADType_OpenScreen) { // 开屏
}else if (adType == ADType_Video){ //视频
[self.vlnVideoAD showAdFromRootViewController:self.currentVC];
[weakSelf.vlnVideoAD showAdFromRootViewController:weakSelf.currentVC];
}else if (adType == ADType_BigImage){ //大图
}
});
}
......
......@@ -65,20 +65,29 @@
/// @param adType 广告类型
- (void)showAdWithData:(GYAdsTrackModel *)showData withADType:(eADType)adType;{
dispatch_async(dispatch_get_main_queue(), ^{
NSString * ADID = showData.codeId;
if (adType == ADType_OpenScreen) { // 开屏
}else if (adType == ADType_Video){ //视频
if ([[WindRewardedVideoAd sharedInstance] isReady:ADID]) {
[[WindRewardedVideoAd sharedInstance] playAd:self.currentVC withPlacementId:ADID options:@{} error:nil];
}else{
self.showSuccessCallbackBlock(showData, NO);
WEAKSELF
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
NSString * ADID = showData.codeId;
if (adType == ADType_OpenScreen) { // 开屏
}else if (adType == ADType_Video){ //视频
if ([[WindRewardedVideoAd sharedInstance] isReady:ADID]) {
NSError * error = nil;
[[WindRewardedVideoAd sharedInstance] playAd:weakSelf.currentVC withPlacementId:ADID options:@{} error:&error];
if (error) {
weakSelf.showSuccessCallbackBlock(showData, NO);
}
}else{
weakSelf.showSuccessCallbackBlock(showData, NO);
}
}else if (adType == ADType_BigImage){ //大图
}
}else if (adType == ADType_BigImage){ //大图
}
});
});
}
......
......@@ -522,20 +522,23 @@
NSLog(@"jumpWebActivity %@", dict);
if ([dict[@"opentype"] integerValue] == 1) {
// 播放视频
WEAKSELF
[[IOSADManager shareADManager] showADType:ADType_Video resultBlock:^(BOOL success) {
if (success) {
[[CGUserManager shared] addLocCollection:@"play_adVideo_end_welfareTask" value:@""];
if ([dict[@"sid"] stringValue].length > 0) {
[[CGNetworkTools shared] postWithAction:welfareVideoReport parameters:@{@"sid": [dict[@"sid"] stringValue]} success:^(id _Nonnull response) {
if ([[response objectForKey:@"status"] integerValue] == 200) {
//
NSLog(@"welfare_video_report success");
[weakSelf.webView reload];
}
} failure:^(NSError * _Nonnull error) {
}];
}
} else {
[MBProgressHUD showError:@"抱歉, 请重试"];
// [MBProgressHUD showError:@"抱歉, 请重试"];
}
}];
} else {
......
......@@ -14,17 +14,17 @@
<key>BaiduMobAd_SDK.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>8</integer>
<integer>9</integer>
</dict>
<key>Bytedance-UnionAD.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>13</integer>
<integer>16</integer>
</dict>
<key>GDTMobSDK.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>17</integer>
<integer>7</integer>
</dict>
<key>KSAdSDK.xcscheme_^#shared#^_</key>
<dict>
......@@ -41,12 +41,12 @@
<key>MJExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>15</integer>
<integer>10</integer>
</dict>
<key>MJRefresh.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>7</integer>
<integer>12</integer>
</dict>
<key>Masonry.xcscheme</key>
<dict>
......@@ -65,12 +65,12 @@
<key>RSPodKSAdaper.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>16</integer>
<integer>8</integer>
</dict>
<key>SigmobAd-iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>9</integer>
<integer>17</integer>
</dict>
<key>SwiftyStoreKit.xcscheme</key>
<dict>
......@@ -82,12 +82,12 @@
<key>UMCCommon.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>10</integer>
<integer>15</integer>
</dict>
<key>VLionAdSDKPoly.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>14</integer>
<integer>13</integer>
</dict>
<key>WechatOpenSDK.xcscheme_^#shared#^_</key>
<dict>
......
This diff is collapsed.
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,7 +12,7 @@
<key>UnityFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>12</integer>
<integer>14</integer>
</dict>
</dict>
</dict>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment