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
e340a1da
Commit
e340a1da
authored
May 04, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ads are no longer initialized if they are disabled via the config.
parent
df86084c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
1Weather/Ads/AdManager.swift
+29
-4
1Weather/Network/Weather/WdtWeatherSource.swift
+0
-1
1Weather/ViewModels/TodayViewModel.swift
+3
-5
No files found.
1Weather/Ads/AdManager.swift
View file @
e340a1da
...
...
@@ -16,12 +16,24 @@ import Flurry_iOS_SDK
public
class
AdManager
{
private
var
lastSetA9AppKey
:
String
?
private
var
lastSetMoPubAppKey
:
String
?
private
var
lastSetUseGeolocation
:
Bool
?
public
static
let
shared
:
AdManager
=
AdManager
()
public
func
start
(
a9AppKey
:
String
,
mopubAppKey
:
String
,
useGeolocation
:
Bool
)
{
guard
!
self
.
initialized
else
{
return
}
self
.
lastSetA9AppKey
=
a9AppKey
self
.
lastSetMoPubAppKey
=
mopubAppKey
self
.
lastSetUseGeolocation
=
useGeolocation
guard
AdConfigManager
.
shared
.
adConfig
.
adsEnabled
else
{
NSLog
(
"psm_ad AdManager [INFO]: not initializing ads, because ads are disabled."
)
return
}
AdLogger
.
setDebugMode
(
Settings
.
shared
.
adLogging
)
...
...
@@ -49,10 +61,9 @@ public class AdManager {
private
func
initializeMoPub
(
initializationAdUnitId
:
String
)
{
let
moPubConfig
=
MPMoPubConfiguration
(
adUnitIdForAppInitialization
:
initializationAdUnitId
)
//any valid placement from the app can be used
moPubConfig
.
loggingLevel
=
AdLogger
.
debugMode
?
MPBLogLevel
.
debug
:
MPBLogLevel
.
none
moPubConfig
.
allowLegitimateInterest
=
true
//
moPubConfig.allowLegitimateInterest = true
moPubConfig
.
additionalNetworks
=
nil
MoPub
.
sharedInstance
()
.
initializeSdk
(
with
:
moPubConfig
)
{
[
weak
self
]
in
...
...
@@ -73,7 +84,8 @@ public class AdManager {
}
private
init
()
{
notificationCenter
.
addObserver
(
self
,
selector
:
#selector(
AdManager.environmentChanged
)
,
name
:
.
AdsEnvironmentChanged
,
object
:
nil
)
notificationCenter
.
addObserver
(
self
,
selector
:
#selector(
environmentChanged
)
,
name
:
.
AdsEnvironmentChanged
,
object
:
nil
)
notificationCenter
.
addObserver
(
self
,
selector
:
#selector(
configChanged
)
,
name
:
.
adConfigChanged
,
object
:
nil
)
}
deinit
{
...
...
@@ -143,9 +155,22 @@ public class AdManager {
return
topViewController
}
@objc
private
func
environmentChanged
()
{
@objc
private
func
environmentChanged
()
{
updateAmazonTestMode
(
for
:
EnvironmentManager
.
shared
.
environment
)
}
@objc
private
func
configChanged
()
{
guard
!
self
.
initialized
&&
AdConfigManager
.
shared
.
adConfig
.
adsEnabled
else
{
return
}
guard
let
a9Key
=
lastSetA9AppKey
,
let
mopubKey
=
lastSetMoPubAppKey
,
let
useGeo
=
lastSetUseGeolocation
else
{
return
}
self
.
start
(
a9AppKey
:
a9Key
,
mopubAppKey
:
mopubKey
,
useGeolocation
:
useGeo
)
}
private
func
updateAmazonTestMode
(
for
environment
:
Environment
)
{
DTBAds
.
sharedInstance
()
.
testMode
=
environment
==
Environment
.
test
...
...
1Weather/Network/Weather/WdtWeatherSource.swift
View file @
e340a1da
...
...
@@ -156,7 +156,6 @@ public class WdtWeatherSource: WeatherSource {
let
locationResponse
=
try
decoder
.
decode
(
WdtHealth
.
self
,
from
:
data
)
var
newLocation
=
location
newLocation
.
today
?
.
uv
=
locationResponse
.
uvIndex
?
.
today
self
.
log
.
debug
(
"DMA Set UV to
\(
locationResponse
.
uvIndex
?
.
today
??
-
1
)
Value after setting:
\(
newLocation
.
today
?
.
uv
??
-
1
)
"
)
completion
(
newLocation
,
nil
)
}
catch
{
...
...
1Weather/ViewModels/TodayViewModel.swift
View file @
e340a1da
...
...
@@ -50,19 +50,17 @@ class TodayViewModel: ViewModelProtocol {
locationManager
.
updateEverythingIfNeeded
()
}
private
var
adsInitialized
=
false
private
func
initializeAllAdsIfNeeded
()
{
onMain
{
guard
!
self
.
adsInitialized
else
{
return
}
self
.
adsInitialized
=
true
let
adManager
=
AdManager
.
shared
guard
!
adManager
.
initialized
else
{
return
}
CCPAHelper
.
shared
.
updateCCPAStatus
(
reason
:
"initialization"
)
if
!
isAppPro
()
{
// In Debug mode we allow the user to change the environment
//TODO AdStack: add MoPub App Key
AdManager
.
shared
.
start
(
a9AppKey
:
a9AppKey
,
mopubAppKey
:
kAdMoPubInitializationAdUnitId
,
useGeolocation
:
true
)
adManager
.
start
(
a9AppKey
:
a9AppKey
,
mopubAppKey
:
kAdMoPubInitializationAdUnitId
,
useGeolocation
:
true
)
// Location SDK setup
let
canCollectData
=
CCPAHelper
.
shared
.
canCollectData
??
false
...
...
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