Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
066578e7
Commit
066578e7
authored
Oct 22, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-16: fix ad events.
parent
dabbae67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
1Weather/Ads/AdView.swift
+1
-1
1Weather/Ads/Native/NativeAdItem.swift
+3
-3
1Weather/Ads/Native/NativeBannerContainerView.swift
+20
-5
No files found.
1Weather/Ads/AdView.swift
View file @
066578e7
...
...
@@ -146,7 +146,7 @@ public class AdView: UIView {
log
.
warning
(
"failed to guess the top view controller."
)
return
}
bannerView
=
NativeBannerContainerView
(
adUnitId
:
placement
.
adUnitId
,
adType
:
adType
,
adLifeCycleTracker
:
adTracker
,
rootViewController
:
topViewController
)
bannerView
=
NativeBannerContainerView
(
placement
:
placement
,
adType
:
adType
,
adLifeCycleTracker
:
adTracker
,
rootViewController
:
topViewController
)
if
let
bannerView
=
bannerView
{
bannerView
.
loggingAlias
=
logName
...
...
1Weather/Ads/Native/NativeAdItem.swift
View file @
066578e7
...
...
@@ -112,19 +112,19 @@ extension NativeAdItem: GADNativeAdDelegate {
extension
NativeAdItem
:
GADBannerViewDelegate
{
func
bannerViewDidRecordImpression
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Impression recorded (banner)"
)
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
)
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adImpression
)
}
func
bannerViewWillPresentScreen
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click recorded (will present screen)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adOpened
)
}
func
adViewWillLeaveApplication
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click recorded (will leave application)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adLeftApplication
)
}
}
1Weather/Ads/Native/NativeBannerContainerView.swift
View file @
066578e7
...
...
@@ -22,6 +22,7 @@ protocol NativeBannerContainerViewDelegate: AnyObject {
class
NativeBannerContainerView
:
UIView
{
private
let
log
=
AdLogger
(
componentName
:
"NativeBannerContainerView"
)
private
let
placement
:
AdPlacement
private
var
adLoader
:
NativeAdLoader
private
let
adType
:
AdType
private
var
adLifeCycleTracker
:
AdLifeCycleTrackable
?
...
...
@@ -33,12 +34,13 @@ class NativeBannerContainerView: UIView {
}
}
init
(
adUnitId
:
String
,
init
(
placement
:
AdPlacement
,
adType
:
AdType
,
adLifeCycleTracker
:
AdLifeCycleTrackable
?
=
nil
,
rootViewController
:
UIViewController
)
{
self
.
placement
=
placement
self
.
adType
=
adType
self
.
adLoader
=
NativeAdLoader
(
adUnitId
:
adUnitId
,
rootViewController
:
rootViewController
,
adTypes
:
[
.
native
,
.
gamBanner
])
self
.
adLoader
=
NativeAdLoader
(
adUnitId
:
placement
.
adUnitId
,
rootViewController
:
rootViewController
,
adTypes
:
[
.
native
,
.
gamBanner
])
self
.
adLifeCycleTracker
=
adLifeCycleTracker
super
.
init
(
frame
:
.
zero
)
self
.
adLoader
.
delegate
=
self
...
...
@@ -60,6 +62,13 @@ class NativeBannerContainerView: UIView {
log
.
componentName
=
"NativeBannerContainerView"
}
}
private
var
analyticsParams
:
[
AnalyticsParameter
:
Any
]
{
return
[
.
ANALYTICS_KEY_PLACEMENT_NAME
:
placement
.
name
,
.
ANALYTICS_KEY_AD_UNIT_ID
:
placement
.
adUnitId
]
}
}
private
extension
NativeBannerContainerView
{
...
...
@@ -112,23 +121,29 @@ extension NativeBannerContainerView: GADBannerViewDelegate {
func
bannerViewDidRecordImpression
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Impression"
)
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
)
var
params
=
analyticsParams
let
adNetworkName
=
bannerView
.
responseInfo
?
.
adNetworkClassName
??
"Ad Network class name not found"
params
[
.
ANALYTICS_KEY_AD_ADAPTER
]
=
adNetworkName
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
,
params
:
params
)
adLifeCycleTracker
?
.
recordAdState
(
.
adImpression
)
}
func
bannerViewWillPresentScreen
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click (will present screen)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adOpened
)
}
func
adViewWillLeaveApplication
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click (will leave application)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adLeftApplication
)
}
func
bannerViewDidRecordClick
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adClicked
)
}
...
...
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