From 4d9f88f23e20bef3f1ff354ad6b8b00caeec8390 Mon Sep 17 00:00:00 2001 From: Abhijeet Ranjan Date: Thu, 5 Jun 2025 15:36:55 +0530 Subject: [PATCH 1/2] Updated the code for showSuspensionScreen and added the trial plan Id as well. --- .../KMConversationListViewController.swift | 4 ++-- .../Classes/KMConversationViewController.swift | 4 ++-- Sources/Kommunicate/Classes/PricingPlan.swift | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Sources/Kommunicate/Classes/KMConversationListViewController.swift b/Sources/Kommunicate/Classes/KMConversationListViewController.swift index 2c85106c..3d2c231d 100644 --- a/Sources/Kommunicate/Classes/KMConversationListViewController.swift +++ b/Sources/Kommunicate/Classes/KMConversationListViewController.swift @@ -486,7 +486,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl } override public func showAccountSuspensionView() { - let accountVC = ALKAccountSuspensionController() + let accountVC = ALKAccountSuspensionController(configuration: configuration) present(accountVC, animated: true, completion: nil) accountVC.isModalInPresentation = true accountVC.closePressed = { [weak self] in @@ -621,7 +621,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl } private func checkPlanAndShowSuspensionScreen() { - let accountVC = ALKAccountSuspensionController() + let accountVC = ALKAccountSuspensionController(configuration: configuration) accountVC.isModalInPresentation = true guard PricingPlan.shared.showSuspensionScreen() else { return } present(accountVC, animated: true, completion: nil) diff --git a/Sources/Kommunicate/Classes/KMConversationViewController.swift b/Sources/Kommunicate/Classes/KMConversationViewController.swift index 1adce2d2..152336c7 100644 --- a/Sources/Kommunicate/Classes/KMConversationViewController.swift +++ b/Sources/Kommunicate/Classes/KMConversationViewController.swift @@ -827,8 +827,8 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate } private func checkPlanAndShowSuspensionScreen() { - let accountVC = ALKAccountSuspensionController() - accountVC.isModalInPresentation = true + let accountVC = ALKAccountSuspensionController(configuration: configuration) + accountVC.isModalInPresentation = true guard PricingPlan.shared.showSuspensionScreen() else { return } present(accountVC, animated: true, completion: nil) accountVC.closePressed = { [weak self] in diff --git a/Sources/Kommunicate/Classes/PricingPlan.swift b/Sources/Kommunicate/Classes/PricingPlan.swift index 047df7f5..980f52c3 100644 --- a/Sources/Kommunicate/Classes/PricingPlan.swift +++ b/Sources/Kommunicate/Classes/PricingPlan.swift @@ -19,6 +19,7 @@ struct PricingPlan { let startupPlan = 101 let startMonthlyPlan = 112 let startYearlyPlan = 113 + let trialPlan = 111 // Business Plans let businessPlans = ["trial", @@ -41,11 +42,17 @@ struct PricingPlan { func showSuspensionScreen() -> Bool { let isReleaseBuild = !utility.isThisDebugBuild() - let isFreePlan = userDefaultsHandler.getUserPricingPackage() == startupPlan - let isStartPlan = (userDefaultsHandler.getUserPricingPackage() == startMonthlyPlan || userDefaultsHandler.getUserPricingPackage() == startYearlyPlan) - let isNotAgent = userDefaultsHandler.getUserRoleType() != Int16(AL_APPLICATION_WEB_ADMIN.rawValue) - guard isReleaseBuild, isNotAgent, isFreePlan || isStartPlan else { return false } - return true + let userPlan = userDefaultsHandler.getUserPricingPackage() + let userRole = userDefaultsHandler.getUserRoleType() + + let isFreeOrStartOrTrialPlan: Bool = { + let startPlans = [startMonthlyPlan, startYearlyPlan] + return userPlan == startupPlan || startPlans.contains(Int(userPlan)) || userPlan == trialPlan + }() + + let isNotAdmin = userRole != Int16(AL_APPLICATION_WEB_ADMIN.rawValue) + + return isReleaseBuild && isNotAdmin && isFreeOrStartOrTrialPlan } func isBusinessPlanOrTrialPlan() -> Bool { From a6803020063294c3a57fea58dc7db2d3beb8f098 Mon Sep 17 00:00:00 2001 From: Abhijeet Ranjan Date: Mon, 9 Jun 2025 16:14:38 +0530 Subject: [PATCH 2/2] updated code for Churned Plan --- Sources/Kommunicate/Classes/PricingPlan.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Kommunicate/Classes/PricingPlan.swift b/Sources/Kommunicate/Classes/PricingPlan.swift index 980f52c3..c620d6d2 100644 --- a/Sources/Kommunicate/Classes/PricingPlan.swift +++ b/Sources/Kommunicate/Classes/PricingPlan.swift @@ -20,6 +20,7 @@ struct PricingPlan { let startMonthlyPlan = 112 let startYearlyPlan = 113 let trialPlan = 111 + let churnedPlan = 100 // Business Plans let businessPlans = ["trial", @@ -47,7 +48,7 @@ struct PricingPlan { let isFreeOrStartOrTrialPlan: Bool = { let startPlans = [startMonthlyPlan, startYearlyPlan] - return userPlan == startupPlan || startPlans.contains(Int(userPlan)) || userPlan == trialPlan + return userPlan == startupPlan || startPlans.contains(Int(userPlan)) || userPlan == trialPlan || userPlan == churnedPlan }() let isNotAdmin = userRole != Int16(AL_APPLICATION_WEB_ADMIN.rawValue)