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
821ff257
Commit
821ff257
authored
Jul 15, 2021
by
Shailesh Aher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IOS-127]: Added tracking in NativeAdItem for better tracking of the adLifeCycle
parent
50e22424
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
1Weather/Ads/Native/NativeAdItem.swift
+12
-2
1Weather/Ads/Native/NativeBannerContainerView.swift
+1
-1
No files found.
1Weather/Ads/Native/NativeAdItem.swift
View file @
821ff257
...
...
@@ -14,6 +14,7 @@ import OneWeatherAnalytics
final
class
NativeAdItem
:
NSObject
{
let
log
=
AdLogger
(
componentName
:
"NativeAdItem"
)
private
var
adLifeCycleTracker
:
AdLifeCycleTrackable
?
enum
AdType
{
case
native
...
...
@@ -47,16 +48,18 @@ final class NativeAdItem: NSObject {
return
nativeAd
!=
nil
?
.
native
:
.
banner
}
init
(
nativeAd
:
GADNativeAd
?,
adUnitId
:
String
?)
{
init
(
nativeAd
:
GADNativeAd
?,
adUnitId
:
String
?
,
adLifeCycleTracker
:
AdLifeCycleTrackable
?
)
{
super
.
init
()
self
.
nativeAd
=
nativeAd
self
.
adLifeCycleTracker
=
adLifeCycleTracker
self
.
nativeAd
?
.
delegate
=
self
self
.
adUnitId
=
adUnitId
}
init
(
bannerAd
:
GAMBannerView
,
adUnitId
:
String
?)
{
init
(
bannerAd
:
GAMBannerView
,
adUnitId
:
String
?
,
adLifeCycleTracker
:
AdLifeCycleTrackable
?
)
{
super
.
init
()
self
.
bannerAd
=
bannerAd
self
.
adLifeCycleTracker
=
adLifeCycleTracker
self
.
bannerAd
?
.
delegate
=
self
self
.
adUnitId
=
adUnitId
}
...
...
@@ -79,20 +82,24 @@ extension NativeAdItem: GADNativeAdDelegate {
params
[
.
ANALYTICS_KEY_AD_ADAPTER
]
=
adNetworkName
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
,
params
:
params
)
adLifeCycleTracker
?
.
recordAdState
(
.
adImpression
)
}
func
nativeAdWillPresentScreen
(
_
nativeAd
:
GADNativeAd
)
{
log
.
debug
(
"NativeAd Will present Modal"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adOpened
)
}
func
nativeAdDidDismissScreen
(
_
nativeAd
:
GADNativeAd
)
{
log
.
debug
(
"NativeAd Did Dismiss screen"
)
adLifeCycleTracker
?
.
recordAdState
(
.
adClosed
)
}
func
nativeAdWillLeaveApplication
(
_
nativeAd
:
GADNativeAd
)
{
log
.
info
(
"NativeAd Will Leave Application"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
,
params
:
analyticsParams
)
adLifeCycleTracker
?
.
recordAdState
(
.
adLeftApplication
)
}
}
...
...
@@ -100,15 +107,18 @@ extension NativeAdItem: GADBannerViewDelegate {
func
bannerViewDidRecordImpression
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Impression recorded (banner)"
)
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
)
adLifeCycleTracker
?
.
recordAdState
(
.
adImpression
)
}
func
bannerViewWillPresentScreen
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click recorded (will present screen)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
adLifeCycleTracker
?
.
recordAdState
(
.
adOpened
)
}
func
adViewWillLeaveApplication
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click recorded (will leave application)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
adLifeCycleTracker
?
.
recordAdState
(
.
adLeftApplication
)
}
}
1Weather/Ads/Native/NativeBannerContainerView.swift
View file @
821ff257
...
...
@@ -84,7 +84,7 @@ extension NativeBannerContainerView: NativeAdLoaderDelegate {
func
adLoader
(
_
adLoader
:
GADAdLoader
,
didReceive
nativeAd
:
GADNativeAd
)
{
log
.
debug
(
"Banner ad recieved (native_banner) by:
\(
String
(
describing
:
nativeAd
.
responseInfo
.
adNetworkClassName
)
)
"
)
guard
let
adView
=
NativeAdView
.
instantiateWithXib
(
adType
:
adType
)
else
{
return
}
let
nativeAdItem
=
NativeAdItem
(
nativeAd
:
nativeAd
,
adUnitId
:
adLoader
.
adUnitID
)
let
nativeAdItem
=
NativeAdItem
(
nativeAd
:
nativeAd
,
adUnitId
:
adLoader
.
adUnitID
,
adLifeCycleTracker
:
adLifeCycleTracker
)
adView
.
nativeAdItem
=
nativeAdItem
addAsSubview
(
view
:
adView
)
print
(
"native ad loader:
\(
String
(
describing
:
nativeAd
.
headline
)
)
"
)
...
...
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