Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
LuckFarm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
LuckFarm
Commits
93c765ca
Commit
93c765ca
authored
Nov 13, 2020
by
zhangshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 广告bug
parent
f19e326b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
170 additions
and
109 deletions
+170
-109
CGNetworkTools.m
GYDemo/GYDemo/Network/CGNetworkTools.m
+1
-0
IOSADManager.m
GYDemo/GYDemo/SCAds/IOSADManager.m
+114
-66
AddCSJADManager.m
GYDemo/GYDemo/SCAds/platform/AddCSJADManager.m
+14
-10
AddGDTADManager.m
GYDemo/GYDemo/SCAds/platform/AddGDTADManager.m
+13
-11
AddRuiShiADManager.m
GYDemo/GYDemo/SCAds/platform/AddRuiShiADManager.m
+13
-9
AddSigmobADManager.m
GYDemo/GYDemo/SCAds/platform/AddSigmobADManager.m
+15
-13
No files found.
GYDemo/GYDemo/Network/CGNetworkTools.m
View file @
93c765ca
...
...
@@ -357,6 +357,7 @@ static CGNetworkTools* _tools = nil;
if
([[
data
Read
]
objectForKey
:
@"source"
])
{
[
dict
setValue
:
[[
data
Read
]
objectForKey
:
@"source"
]
forKey
:
@"source"
];
}
[
dict
setValue
:
@"toutiao"
forKey
:
@"source"
];
NSString
*
uid
=
[[
data
Read
]
objectForKey
:
@"uid"
];
if
(
uid
!=
nil
)
{
[
dict
setValue
:
uid
forKey
:
@"uid"
];
}
...
...
GYDemo/GYDemo/SCAds/IOSADManager.m
View file @
93c765ca
...
...
@@ -213,9 +213,11 @@ static IOSADManager * manager = nil;
/// @param loadADModel 广告对象
/// @param AdType 广告类型
-
(
void
)
loadAdWithData
:
(
GYAdsTrackModel
*
)
loadADModel
withADType
:
(
eADType
)
AdType
;{
NSLog
(
@">>>>>>> 准备缓存 平台 = %@ ID = %@ type= %@ <<<<<<<<<"
,
loadADModel
.
adPlatform
,
loadADModel
.
codeId
,
loadADModel
.
slotName
);
self
.
haveLodeAD
=
YES
;
loadADModel
.
loadADType
=
AdType
;
if
([
self
.
loadADDataArray
count
]
>
6
)
{
if
([
self
.
loadADDataArray
count
]
>
10
)
{
[
self
.
loadADDataArray
removeObject
:
self
.
loadADDataArray
.
firstObject
];
}
WEAKSELF
;
...
...
@@ -231,11 +233,10 @@ static IOSADManager * manager = nil;
time
=
5
;
}
// 去加载
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
time
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
self
.
csjAd
=
nil
;
weakSelf
.
csjAd
=
nil
;
AddCSJADManager
*
csjAd
=
[[
AddCSJADManager
alloc
]
init
];
s
elf
.
csjAd
=
csjAd
;
[
s
elf
.
loadADDataArray
addObject
:
csjAd
];
weakS
elf
.
csjAd
=
csjAd
;
[
weakS
elf
.
loadADDataArray
addObject
:
csjAd
];
[
csjAd
loadAdWithData
:
loadADModel
withADType
:
AdType
];
...
...
@@ -245,6 +246,8 @@ static IOSADManager * manager = nil;
csjAd
.
showSuccessCallbackBlock
=
^
(
GYAdsTrackModel
*
_Nonnull
model
,
BOOL
success
)
{
[
weakSelf
blockResultShowWithData
:
model
andSuccess
:
YES
];
};
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
time
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
});
}
...
...
@@ -312,8 +315,8 @@ static IOSADManager * manager = nil;
}
}
else
{
if
(
AdType
==
ADType_Video
)
{
// 视频
GYAdsTrackModel
*
adData
=
loadADModel
;
if
(
self
.
videoModels
.
count
>
self
.
cachevideo
.
count
)
{
GYAdsTrackModel
*
adData
=
self
.
videoModels
[
self
.
cachevideo
.
count
]
;
NSLog
(
@">>>>>>> 缓存 失败 %@ 不支持"
,
adData
.
adPlatform
);
if
(
adData
.
firstFailure
==
NO
)
{
...
...
@@ -332,6 +335,10 @@ static IOSADManager * manager = nil;
[
self
requestVideoAD
];
}
}
}
else
{
[
self
requestVideoAD
];
}
}
else
if
(
AdType
==
ADType_OpenScreen
){
...
...
@@ -375,27 +382,26 @@ static IOSADManager * manager = nil;
/// @param adType 广告类型
-
(
void
)
showAdWithData
:
(
GYAdsTrackModel
*
)
showData
withADType
:
(
eADType
)
adType
;{
if
(
adType
==
ADType_Video
)
{
// 视频
NSLog
(
@">>>>>>> 正在播放 成功 平台 = %@ ID = %@
<<<<<<<<<"
,
showData
.
adPlatform
,
showData
.
codeId
);
NSLog
(
@">>>>>>> 正在播放 成功 平台 = %@ ID = %@
type =%@ <<<<<<<<<"
,
showData
.
adPlatform
,
showData
.
codeId
,
showData
.
slotName
);
WEAKSELF
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
([
showData
.
adPlatform
isEqualToString
:
@"chuanshanjia"
])
{
[
s
elf
.
csjAd
showAdWithData
:
showData
withADType
:
adType
];
[
weakS
elf
.
csjAd
showAdWithData
:
showData
withADType
:
adType
];
}
else
if
([
showData
.
adPlatform
isEqualToString
:
@"guangdiantong"
]){
[
s
elf
.
gdtAd
showAdWithData
:
showData
withADType
:
adType
];
[
weakS
elf
.
gdtAd
showAdWithData
:
showData
withADType
:
adType
];
}
else
if
([
showData
.
adPlatform
isEqualToString
:
@"sigmob"
]){
[
s
elf
.
sigmobAd
showAdWithData
:
showData
withADType
:
adType
];
[
weakS
elf
.
sigmobAd
showAdWithData
:
showData
withADType
:
adType
];
}
else
if
([
showData
.
adPlatform
isEqualToString
:
@"ruishi"
]){
[
s
elf
.
ruishiAd
showAdWithData
:
showData
withADType
:
adType
];
[
weakS
elf
.
ruishiAd
showAdWithData
:
showData
withADType
:
adType
];
}
if
(
self
.
videoModels
.
count
<=
1
)
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
1
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
[
weakSelf
requestVideoAD
];
});
if
(
weakSelf
.
videoModels
.
count
<=
1
)
{
[
weakSelf
requestVideoAD
];
}
else
{
[
self
loadAdWithData
:
s
elf
.
videoModels
[
1
]
withADType
:
ADType_Video
];
[
weakSelf
loadAdWithData
:
weakS
elf
.
videoModels
[
1
]
withADType
:
ADType_Video
];
}
}
else
if
(
adType
==
ADType_BigImage
){
//大图
...
...
@@ -423,8 +429,9 @@ static IOSADManager * manager = nil;
-
(
void
)
requestOpenScreenAD
;{
WEAKSELF
;
[[
CGNetworkTools
shared
]
getWithAdsAction
:
getAdsInfo
parameters
:
@{
@"slotName"
:
@"splash"
}
success
:^
(
id
_Nonnull
response
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
if
([[
response
objectForKey
:
@"status"
]
intValue
]
==
200
)
{
[[
CGUserManager
shared
]
addLocCollection
:
@"splash_request"
value
:
@"splash_request_success"
];
NSMutableArray
*
models
=
[
NSMutableArray
new
];
...
...
@@ -452,8 +459,9 @@ static IOSADManager * manager = nil;
[[
CGUserManager
shared
]
addLocCollection
:
@"splash_request"
value
:
@"splash_request_failed"
];
}
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
[[
CGUserManager
shared
]
addLocCollection
:
@"splash_request"
value
:
@"splash_request_failed"
];
}];
}
...
...
@@ -461,8 +469,9 @@ static IOSADManager * manager = nil;
-
(
void
)
requestNativeAD
;{
WEAKSELF
;
[[
CGNetworkTools
shared
]
getWithAdsAction
:
getAdsInfo
parameters
:
@{
@"slotName"
:
@"common_bigimage"
}
success
:^
(
id
_Nonnull
response
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
if
([[
response
objectForKey
:
@"status"
]
intValue
]
==
200
)
{
[[
CGUserManager
shared
]
addLocCollection
:
@"native_request"
value
:
@"native_request_success"
];
...
...
@@ -490,8 +499,9 @@ static IOSADManager * manager = nil;
}
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
[[
CGUserManager
shared
]
addLocCollection
:
@"native_request"
value
:
@"native_request_failed"
];
}];
...
...
@@ -510,8 +520,9 @@ static IOSADManager * manager = nil;
}
[[
CGNetworkTools
shared
]
getWithAdsAction
:
getAdsInfo
parameters
:
@{
@"slotName"
:
@"common_video"
}
success
:^
(
id
_Nonnull
response
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
if
([[
response
objectForKey
:
@"status"
]
intValue
]
==
200
)
{
requestToTry
=
0
;
...
...
@@ -551,12 +562,14 @@ static IOSADManager * manager = nil;
[[
CGUserManager
shared
]
addLocCollection
:
@"reward_request"
value
:
@"reward_request_failed"
];
}
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
requestToTry
+=
1
;
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
2
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
[
weakSelf
requestVideoAD
];
});
//
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//
[weakSelf requestVideoAD];
//
});
[[
CGUserManager
shared
]
addLocCollection
:
@"reward_request"
value
:
@"reward_request_failed"
];
}];
...
...
@@ -576,21 +589,56 @@ static IOSADManager * manager = nil;
NSLog
(
@">>>>>>> 缓存 失败 平台 = %@ ID = %@ type= %@ <<<<<<<<<"
,
model
.
adPlatform
,
model
.
codeId
,
model
.
slotName
);
}
if
(
model
.
loadADType
==
ADType_Video
){
weakSelf
.
haveLodeAD
=
NO
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
MBProgressHUD
hideHUD
];
});
if
(
success
)
{
[[
CGUserManager
shared
]
addLocCollection
:
@"reward_request"
value
:
@"reward_back_success"
];
[
weakSelf
.
cachevideo
addObject
:
model
];
if
(
weakSelf
.
showNow
){
[
weakSelf
showADType
:
ADType_Video
resultBlock
:
s
elf
.
adShowBlock
];
[
weakSelf
showADType
:
ADType_Video
resultBlock
:
weakS
elf
.
adShowBlock
];
}
}
else
{
if
(
weakSelf
.
videoModels
.
count
>
weakSelf
.
cachevideo
.
count
)
{
GYAdsTrackModel
*
firstData
=
weakSelf
.
videoModels
[
weakSelf
.
cachevideo
.
count
];
[[
CGUserManager
shared
]
addLocCollection
:
@"reward_request"
value
:
@"reward_back_failed"
];
[
weakSelf
clearCache
:
model
];
if
(
firstData
.
firstFailure
==
NO
)
{
firstData
.
firstFailure
=
YES
;
}
else
{
[
firstData
.
backups
removeObject
:
firstData
.
backups
.
firstObject
];
}
if
(
firstData
.
backups
.
count
)
{
[
weakSelf
loadAdWithData
:
firstData
.
backups
.
firstObject
withADType
:
ADType_Video
];
}
else
{
[
weakSelf
.
videoModels
removeObject
:
firstData
];
if
(
weakSelf
.
videoModels
.
count
)
{
[
weakSelf
loadAdWithData
:
weakSelf
.
videoModels
.
firstObject
withADType
:
ADType_Video
];
}
else
{
[
weakSelf
requestVideoAD
];
}
}
}
else
{
[
weakSelf
requestVideoAD
];
}
}
// dispatch_queue_t queueglobal = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
//
// dispatch_async(queueglobal, ^{
//
// });
}
else
if
(
model
.
loadADType
==
ADType_OpenScreen
){
...
...
GYDemo/GYDemo/SCAds/platform/AddCSJADManager.m
View file @
93c765ca
...
...
@@ -72,6 +72,7 @@
/// @param adType 广告类型
-
(
void
)
showAdWithData
:(
GYAdsTrackModel
*
)
showData
withADType
:(
eADType
)
adType
;{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
adType
==
ADType_OpenScreen
)
{
// 开屏
}
else
if
(
adType
==
ADType_Video
){
//视频
...
...
@@ -83,6 +84,9 @@
}
else
if
(
adType
==
ADType_BigImage
){
//大图
}
});
}
...
...
GYDemo/GYDemo/SCAds/platform/AddGDTADManager.m
View file @
93c765ca
...
...
@@ -66,7 +66,7 @@
/// @param showData 广告对象
/// @param adType 广告类型
-
(
void
)
showAdWithData
:(
GYAdsTrackModel
*
)
showData
withADType
:(
eADType
)
adType
;{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
adType
==
ADType_OpenScreen
)
{
// 开屏
}
else
if
(
adType
==
ADType_Video
){
//视频
...
...
@@ -78,6 +78,8 @@
}
else
if
(
adType
==
ADType_BigImage
){
//大图
}
});
}
//MARK:开屏
...
...
GYDemo/GYDemo/SCAds/platform/AddRuiShiADManager.m
View file @
93c765ca
...
...
@@ -62,6 +62,7 @@
/// @param adType 广告类型
-
(
void
)
showAdWithData
:(
GYAdsTrackModel
*
)
showData
withADType
:(
eADType
)
adType
;{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
adType
==
ADType_OpenScreen
)
{
// 开屏
}
else
if
(
adType
==
ADType_Video
){
//视频
...
...
@@ -71,6 +72,9 @@
}
else
if
(
adType
==
ADType_BigImage
){
//大图
}
});
}
...
...
GYDemo/GYDemo/SCAds/platform/AddSigmobADManager.m
View file @
93c765ca
...
...
@@ -57,9 +57,9 @@
/// @param showData 广告对象
/// @param adType 广告类型
-
(
void
)
showAdWithData
:(
GYAdsTrackModel
*
)
showData
withADType
:(
eADType
)
adType
;{
NSString
*
ADID
=
showData
.
codeId
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
NSString
*
ADID
=
showData
.
codeId
;
if
(
adType
==
ADType_OpenScreen
)
{
// 开屏
}
else
if
(
adType
==
ADType_Video
){
//视频
...
...
@@ -71,6 +71,8 @@
}
else
if
(
adType
==
ADType_BigImage
){
//大图
}
});
}
//MARK: ---- 开屏 ----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment