Skip to content

Commit 1f6f688

Browse files
authored
Merge pull request #502 from Kommunicate-io/CM-2439
[CM-2439] Update UI Message to Indicate Subscription Requirement in Release Mode | iOS SDK
2 parents 393e84d + a680302 commit 1f6f688

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Sources/Kommunicate/Classes/KMConversationListViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl
486486
}
487487

488488
override public func showAccountSuspensionView() {
489-
let accountVC = ALKAccountSuspensionController()
489+
let accountVC = ALKAccountSuspensionController(configuration: configuration)
490490
present(accountVC, animated: true, completion: nil)
491491
accountVC.isModalInPresentation = true
492492
accountVC.closePressed = { [weak self] in
@@ -621,7 +621,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl
621621
}
622622

623623
private func checkPlanAndShowSuspensionScreen() {
624-
let accountVC = ALKAccountSuspensionController()
624+
let accountVC = ALKAccountSuspensionController(configuration: configuration)
625625
accountVC.isModalInPresentation = true
626626
guard PricingPlan.shared.showSuspensionScreen() else { return }
627627
present(accountVC, animated: true, completion: nil)

Sources/Kommunicate/Classes/KMConversationViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
827827
}
828828

829829
private func checkPlanAndShowSuspensionScreen() {
830-
let accountVC = ALKAccountSuspensionController()
831-
accountVC.isModalInPresentation = true
830+
let accountVC = ALKAccountSuspensionController(configuration: configuration)
831+
accountVC.isModalInPresentation = true
832832
guard PricingPlan.shared.showSuspensionScreen() else { return }
833833
present(accountVC, animated: true, completion: nil)
834834
accountVC.closePressed = { [weak self] in

Sources/Kommunicate/Classes/PricingPlan.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct PricingPlan {
1919
let startupPlan = 101
2020
let startMonthlyPlan = 112
2121
let startYearlyPlan = 113
22+
let trialPlan = 111
23+
let churnedPlan = 100
2224

2325
// Business Plans
2426
let businessPlans = ["trial",
@@ -41,11 +43,17 @@ struct PricingPlan {
4143

4244
func showSuspensionScreen() -> Bool {
4345
let isReleaseBuild = !utility.isThisDebugBuild()
44-
let isFreePlan = userDefaultsHandler.getUserPricingPackage() == startupPlan
45-
let isStartPlan = (userDefaultsHandler.getUserPricingPackage() == startMonthlyPlan || userDefaultsHandler.getUserPricingPackage() == startYearlyPlan)
46-
let isNotAgent = userDefaultsHandler.getUserRoleType() != Int16(AL_APPLICATION_WEB_ADMIN.rawValue)
47-
guard isReleaseBuild, isNotAgent, isFreePlan || isStartPlan else { return false }
48-
return true
46+
let userPlan = userDefaultsHandler.getUserPricingPackage()
47+
let userRole = userDefaultsHandler.getUserRoleType()
48+
49+
let isFreeOrStartOrTrialPlan: Bool = {
50+
let startPlans = [startMonthlyPlan, startYearlyPlan]
51+
return userPlan == startupPlan || startPlans.contains(Int(userPlan)) || userPlan == trialPlan || userPlan == churnedPlan
52+
}()
53+
54+
let isNotAdmin = userRole != Int16(AL_APPLICATION_WEB_ADMIN.rawValue)
55+
56+
return isReleaseBuild && isNotAdmin && isFreeOrStartOrTrialPlan
4957
}
5058

5159
func isBusinessPlanOrTrialPlan() -> Bool {

0 commit comments

Comments
 (0)