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
a936f5c7
Commit
a936f5c7
authored
Oct 20, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IOS-287]: Moved presentation logic to FeatureAvailabilityManager
parent
c5aa9e6c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
5 deletions
+44
-5
1Weather/AppDelegate.swift
+14
-0
1Weather/Configuration/LocalConfig.plist
+2
-0
1Weather/Network/Configuration/ConfigManager.swift
+16
-1
1Weather/UI/View controllers/Subscriptions/SubscriptionPopUpViewController.swift
+1
-1
1Weather/ViewModels/TodayViewModel.swift
+1
-1
OneWeatherCore/OneWeatherCore/Managers/FeatureAvailability/AppFeature.swift
+2
-0
OneWeatherCore/OneWeatherCore/ModelObjects/Config/AppConfig.swift
+6
-0
OneWeatherCore/OneWeatherCore/Settings/Settings.swift
+2
-2
No files found.
1Weather/AppDelegate.swift
View file @
a936f5c7
...
...
@@ -231,6 +231,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
return
storeManager
.
everHadSubscription
}
let
initialSubscriptionShown
=
ClosureFeatureAvailabilityChecker
{
return
Settings
.
shared
.
initialSubscriptionShown
}
let
ccpaHelper
=
CCPAHelper
.
shared
let
firstTimeUser
=
ClosureFeatureAvailabilityChecker
{
[
weak
ccpaHelper
]
in
guard
let
ccpaHelper
=
ccpaHelper
else
{
return
false
}
return
ccpaHelper
.
isNewUser
}
let
isPhone
=
DeviceTypeFeatureAvailabilityChecker
(
deviceType
:
.
phone
)
...
...
@@ -257,6 +267,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
break
// config only
case
.
subscription
:
break
// configOnly
case
.
subscriptionNudge
:
break
//config only
case
.
initialSubscriptionNudge
:
availabilityCheckers
[
feature
]
=
!
initialSubscriptionShown
&&
firstTimeUser
&&
!
premium
case
.
subscriptionForPro
:
availabilityCheckers
[
feature
]
=
premium
case
.
extendedDailyForecast
:
...
...
1Weather/Configuration/LocalConfig.plist
View file @
a936f5c7
...
...
@@ -31,6 +31,8 @@
&
quot
;
a9_refresh_rate
&
quot
;
:
0
,
&
quot
;
placements
&
quot
;
:
{}
}<
/string
>
<
k
e
y
>
ios_premium_nudge_show_to_ftu
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
ios_terceptsdk_enabled
<
/k
e
y
>
<
tru
e
/
>
<
/
d
i
c
t
>
...
...
1Weather/Network/Configuration/ConfigManager.swift
View file @
a936f5c7
...
...
@@ -23,6 +23,8 @@ public class ConfigManager {
private
static
let
shortsLeftBelowCountKey
=
"shorts_left_below_nudge_every_x_cards"
private
static
let
shortsSwipeUpNudgeCountKey
=
"shorts_swipe_up_nudge_on_x_cards"
private
static
let
subscriptionConfigKey
=
"ios_subscription_config"
private
static
let
premiumNudgeSessionShowing
=
"ios_premium_nudge_sessions_between_showing"
private
static
let
premiumNudgeTotalTimes
=
"ios_premium_nudge_total_times_to_show"
private
let
delegates
=
MulticastDelegate
<
ConfigManagerDelegate
>
()
...
...
@@ -43,10 +45,13 @@ public class ConfigManager {
ccpaUpdateInterval
:
nil
,
shortsLeftBelowCountKey
:
0
,
shortsSwipeUpNudgeCountKey
:
0
,
premiumNudgeSessionShowing
:
0
,
premiumNudgeTotalTimes
:
0
,
explicitFeatureAvailability
:
[
.
nwsAlertsViaMoEngage
:
true
,
.
attPrompt
:
false
,
.
shortsLastNudge
:
false
,
.
subscriptionNudge
:
false
,
.
onboarding
:
false
,
.
terceptSdk
:
false
],
subscriptionsConfig
:
SubscriptionsListConfig
()
...
...
@@ -142,6 +147,12 @@ public class ConfigManager {
let
shortsSwipeNudgeCountValue
=
remoteConfig
.
configValue
(
forKey
:
ConfigManager
.
shortsSwipeUpNudgeCountKey
)
let
shortsSwipeNudgeCount
=
shortsSwipeNudgeCountValue
.
numberValue
.
intValue
let
premiumNudgeSessionShownigValue
=
remoteConfig
.
configValue
(
forKey
:
ConfigManager
.
premiumNudgeSessionShowing
)
let
premiumNudgeSessionShowngCount
=
premiumNudgeSessionShownigValue
.
numberValue
.
intValue
let
premiumNudgeTotalTimesValue
=
remoteConfig
.
configValue
(
forKey
:
ConfigManager
.
premiumNudgeTotalTimes
)
let
premiumNudgeTotalTimesCount
=
premiumNudgeTotalTimesValue
.
numberValue
.
intValue
let
featureAvailability
=
parseFeatureAvailability
()
var
subscriptionsConfig
=
SubscriptionsListConfig
()
...
...
@@ -161,6 +172,8 @@ public class ConfigManager {
ccpaUpdateInterval
:
ccpaUpdateInterval
,
shortsLeftBelowCountKey
:
shortsLeftBelowCount
,
shortsSwipeUpNudgeCountKey
:
shortsSwipeNudgeCount
,
premiumNudgeSessionShowing
:
premiumNudgeSessionShowngCount
,
premiumNudgeTotalTimes
:
premiumNudgeTotalTimesCount
,
explicitFeatureAvailability
:
featureAvailability
,
subscriptionsConfig
:
subscriptionsConfig
)
...
...
@@ -194,11 +207,13 @@ fileprivate extension AppFeature {
return
"ios_show_att_prompt"
case
.
shortsLastNudge
:
return
"shorts_swipe_down_nudge_enabled"
case
.
subscriptionNudge
:
return
"ios_premium_nudge_show_to_ftu"
case
.
onboarding
:
return
"ios_show_onboarding"
case
.
terceptSdk
:
return
"ios_terceptsdk_enabled"
case
.
ads
,
.
airQualityIndex
,
.
minutelyForecast
,
.
shorts
,
.
subscription
,
.
subscriptionForPro
,
.
extendedDailyForecast
,
.
extendedHourlyForecast
:
case
.
ads
,
.
airQualityIndex
,
.
minutelyForecast
,
.
shorts
,
.
subscription
,
.
subscriptionForPro
,
.
extendedDailyForecast
,
.
extendedHourlyForecast
,
.
initialSubscriptionNudge
:
return
nil
// don't use 'default', so that we didn't add new features here in the future.
}
...
...
1Weather/UI/View controllers/Subscriptions/SubscriptionPopUpViewController.swift
View file @
a936f5c7
...
...
@@ -41,7 +41,7 @@ class SubscriptionPopUpViewController: UIViewController {
self
.
view
.
layoutIfNeeded
()
}
Settings
.
shared
.
initialSubscriptionShow
ed
=
true
Settings
.
shared
.
initialSubscriptionShow
n
=
true
}
}
...
...
1Weather/ViewModels/TodayViewModel.swift
View file @
a936f5c7
...
...
@@ -103,7 +103,7 @@ class TodayViewModel: ViewModelProtocol {
self
.
initializeAllAdsIfNeeded
()
PushNotificationsManager
.
shared
.
registerForRemoteNotifications
(
completion
:
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
if
!
Settings
.
shared
.
initialSubscriptionShowed
&&
CCPAHelper
.
shared
.
isNewUser
{
if
self
.
featureAvailabilityManager
.
isAvailable
(
feature
:
.
initialSubscriptionNudge
)
{
self
.
delegate
?
.
showSubscriptionPopup
(
viewModel
:
self
)
}
})
...
...
OneWeatherCore/OneWeatherCore/Managers/FeatureAvailability/AppFeature.swift
View file @
a936f5c7
...
...
@@ -22,5 +22,7 @@ public enum AppFeature: String, Codable, CaseIterable {
case
subscription
/// Discounted subscription for people who previously purchased an in-app to remove ads
case
subscriptionForPro
case
subscriptionNudge
case
initialSubscriptionNudge
case
terceptSdk
}
OneWeatherCore/OneWeatherCore/ModelObjects/Config/AppConfig.swift
View file @
a936f5c7
...
...
@@ -15,12 +15,16 @@ public struct AppConfig: Codable {
public
let
shortsSwipeUpNudgeCount
:
Int
private
let
explicitFeatureAvailability
:
[
AppFeature
:
Bool
]
public
let
subscriptionsConfig
:
SubscriptionsListConfig
public
let
premiumNudgeSessionShowing
:
Int
public
let
premiumNudgeTotalTimes
:
Int
public
init
(
popularCities
:
[
GeoNamesPlace
]?,
adConfig
:
AdConfig
,
ccpaUpdateInterval
:
TimeInterval
?,
shortsLeftBelowCountKey
:
Int
,
shortsSwipeUpNudgeCountKey
:
Int
,
premiumNudgeSessionShowing
:
Int
,
premiumNudgeTotalTimes
:
Int
,
explicitFeatureAvailability
:
[
AppFeature
:
Bool
],
subscriptionsConfig
:
SubscriptionsListConfig
)
{
...
...
@@ -31,6 +35,8 @@ public struct AppConfig: Codable {
self
.
shortsSwipeUpNudgeCount
=
shortsSwipeUpNudgeCountKey
self
.
explicitFeatureAvailability
=
explicitFeatureAvailability
self
.
subscriptionsConfig
=
subscriptionsConfig
self
.
premiumNudgeSessionShowing
=
premiumNudgeSessionShowing
self
.
premiumNudgeTotalTimes
=
premiumNudgeTotalTimes
}
public
func
isEnabled
(
feature
:
AppFeature
)
->
Bool
{
...
...
OneWeatherCore/OneWeatherCore/Settings/Settings.swift
View file @
a936f5c7
...
...
@@ -101,8 +101,8 @@ public class Settings {
@UserDefaultsBasicValue(key: "shorts_showed_swipeUp_count", userDefaults: UserDefaults.appDefaults)
public
var
shortsSwipeUpNudgeShowedCount
=
0
@UserDefaultsBasicValue(key: "initial_subscription_show
ed
", userDefaults: UserDefaults.appDefaults)
public
var
initialSubscriptionShow
ed
=
false
@UserDefaultsBasicValue(key: "initial_subscription_show
n
", userDefaults: UserDefaults.appDefaults)
public
var
initialSubscriptionShow
n
=
false
#warning("Not implemented!")
//TODO: implement store in UserDefaults and configure via UI in debug builds.
...
...
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