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
72ede3bb
Commit
72ede3bb
authored
Apr 29, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a new LAST_SEEN_FIPS_CODE_NON_TRACFONE attribute for NWSAlerts targeting.
parent
87102046
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
1Weather/Model/LocationManager.swift
+2
-2
1Weather/Network/PushNotificationsManager.swift
+13
-4
No files found.
1Weather/Model/LocationManager.swift
View file @
72ede3bb
...
...
@@ -256,7 +256,7 @@ public class LocationManager {
updateNotifications
(
for
:
location
)
getFipsIfNeeded
(
for
:
location
)
}
pushNotificationsManager
.
updateNwsSubscriptions
(
for
:
locations
)
pushNotificationsManager
.
updateNwsSubscriptions
(
for
:
locations
,
selectedLocation
:
selectedLocation
)
}
public
func
getFipsIfNeeded
(
for
location
:
Location
)
{
...
...
@@ -269,7 +269,7 @@ public class LocationManager {
return
updatedLocation
},
completion
:
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
self
.
pushNotificationsManager
.
updateNwsSubscriptions
(
for
:
self
.
locations
)
self
.
pushNotificationsManager
.
updateNwsSubscriptions
(
for
:
self
.
locations
,
selectedLocation
:
self
.
selectedLocation
)
})
}
}
...
...
1Weather/Network/PushNotificationsManager.swift
View file @
72ede3bb
...
...
@@ -49,26 +49,35 @@ public class PushNotificationsManager: NSObject {
}
}
private
var
lastSetFIPSList
:
String
?
=
""
internal
var
lastSetFIPSList
:
String
?
=
""
internal
var
lastSetFIPSCode
:
String
?
=
""
private
func
updateNwsSubscriptions
(
with
fipsList
:
String
?)
{
private
func
updateNwsSubscriptions
(
with
fipsList
:
String
?,
currentFipsCode
:
String
?)
{
let
lastFipsCodeAttributeName
=
"LAST_SEEN_FIPS_CODE_NON_TRACFONE"
if
configManager
.
config
.
nwsAlertsViaMoEngageEnabled
{
if
fipsList
!=
lastSetFIPSList
{
log
.
info
(
"Set FIPS_LIST to '
\(
fipsList
??
""
)
'"
)
lastSetFIPSList
=
fipsList
}
if
currentFipsCode
!=
lastSetFIPSCode
{
log
.
info
(
"Set
\(
lastFipsCodeAttributeName
)
to '
\(
currentFipsCode
??
""
)
'"
)
lastSetFIPSCode
=
currentFipsCode
}
}
else
{
log
.
info
(
"Set FIPS_LIST to nil, because nwsAlertsViaMoEngage are disabled via config."
)
log
.
info
(
"Set
\(
lastFipsCodeAttributeName
)
to nil, because nwsAlertsViaMoEngage are disabled via config"
)
log
.
info
(
"Set "
)
lastSetFIPSList
=
nil
}
MoEngage
.
sharedInstance
()
.
setUserAttribute
(
lastSetFIPSList
,
forKey
:
"FIPS_LIST"
)
MoEngage
.
sharedInstance
()
.
setUserAttribute
(
lastSetFIPSCode
,
forKey
:
lastFipsCodeAttributeName
)
}
public
func
updateNwsSubscriptions
(
for
locations
:
[
Location
])
{
public
func
updateNwsSubscriptions
(
for
locations
:
[
Location
]
,
selectedLocation
:
Location
?
)
{
let
fipsCodes
=
locations
.
compactMap
{
$0
.
fipsCode
}
let
newFipsList
=
fipsCodes
.
joined
(
separator
:
","
)
updateNwsSubscriptions
(
with
:
newFipsList
)
updateNwsSubscriptions
(
with
:
newFipsList
,
currentFipsCode
:
selectedLocation
?
.
fipsCode
)
}
public
func
set
(
pushToken
:
Data
)
{
...
...
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